using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Data; using System.Windows.Media; namespace BPASmartClient.Academy.Converter { public class MultiBoolToColorConverter : IMultiValueConverter { public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { if (parameter is string colorString) { string[] colorStr=colorString.Split(','); for (int i = 0; i < values.Length; i++) { if (values[i] is bool b && i < colorStr.Length) { if (b) { try { var color = (SolidColorBrush)new BrushConverter().ConvertFromString(colorStr[i]); return color.Color; } catch (Exception) { throw; } } } } } //返回透明色。 return Brushes.White.Color; } public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) { throw new NotImplementedException(); } } }