MiddleStatusToColor.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows.Data;
  7. using System.Windows.Media;
  8. namespace CyberX8_MainPages.Converters
  9. {
  10. public class MiddleStatusToColor : IValueConverter
  11. {
  12. public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  13. {
  14. if(value==null)
  15. {
  16. return new SolidColorBrush(Colors.Gray);
  17. }
  18. else
  19. {
  20. int status = (int)value;
  21. if(status==1)
  22. {
  23. return new SolidColorBrush(Colors.Lime);
  24. }
  25. else if(status==0)
  26. {
  27. return new SolidColorBrush(Colors.Gray);
  28. }
  29. else
  30. {
  31. return new SolidColorBrush(Colors.Yellow);
  32. }
  33. }
  34. }
  35. public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  36. {
  37. return null;
  38. }
  39. }
  40. }