using System.ComponentModel; using System.Globalization; using System.Windows; namespace HKW.WPF.Converters; /// /// 全部为布尔值转换器 /// public class AllIsBoolConverter : MultiValueToBoolConverter { /// /// /// public static readonly DependencyProperty BoolOnNullProperty = DependencyProperty.Register( nameof(BoolOnNull), typeof(bool), typeof(AllIsBoolConverter), new PropertyMetadata(false) ); /// /// 目标为空时的指定值 /// [DefaultValue(false)] public bool BoolOnNull { get => (bool)GetValue(BoolOnNullProperty); set => SetValue(BoolOnNullProperty, value); } /// /// /// /// /// /// /// /// /// public override object Convert( object[] values, Type targetType, object parameter, CultureInfo culture ) { var boolValue = TargetBoolValue; var nullValue = BoolOnNull; return values.All(o => HKWUtils.HKWUtils.GetBool(o, boolValue, nullValue)); } }