ResultColorConverter.cs 670 B

12345678910111213141516171819202122232425
  1. using System;
  2. using System.Globalization;
  3. using System.Windows.Data;
  4. using System.Windows.Media;
  5. namespace LocalhostMES.Converters
  6. {
  7. public class ResultColorConverter : IValueConverter
  8. {
  9. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  10. {
  11. if (value is string result)
  12. {
  13. return result == "OK" ? Brushes.Green : Brushes.Red;
  14. }
  15. return Brushes.Black;
  16. }
  17. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  18. {
  19. throw new NotImplementedException();
  20. }
  21. }
  22. }