add BooleanArr2BooleanConverter

This commit is contained in:
chenjie02_cd committed 2021-09-06 20:06:15 +08:00
1 parent 904b32f986
commit 4d7697914f
5 files changed
+44

No files matched your search

@@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Windows.Data;
using HandyControl.Data;
namespace HandyControl.Tools.Converter
{
public class BooleanArr2BooleanConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
if (values == null)
{
return ValueBoxes.FalseBox;
}
var arr = new List<bool>();
foreach (var item in values)
{
if (item is bool boolValue)
{
arr.Add(boolValue);
}
else
{
return ValueBoxes.FalseBox;
}
}
return ValueBoxes.BooleanBox(arr.All(item => item));
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
throw new NotSupportedException();
}
}
}