using System.Globalization; using System.Windows; using System.Windows.Data; using System.Windows.Media; namespace HMIToolkit; public class BoolToBrushConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (targetType != typeof(Brush)) throw new InvalidOperationException("The target must be a brush"); bool temp = bool.Parse(value.ToString()!); return (temp ? Brushes.DarkGreen : Brushes.DarkRed); } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { return DependencyProperty.UnsetValue; } }