BooleanToColorConverter.cs 715 B

1234567891011121314151617181920212223242526
  1. using System;
  2. using System.Globalization;
  3. using Xamarin.Forms;
  4. namespace InABox.Mobile
  5. {
  6. public class BooleanToColorConverter: BindableObject, IValueConverter
  7. {
  8. public Color TrueColor { get; set; }
  9. public Color FalseColor { get; set; }
  10. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  11. {
  12. if (value is bool bValue)
  13. return bValue ? TrueColor : FalseColor;
  14. return FalseColor;
  15. }
  16. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  17. {
  18. throw new NotImplementedException();
  19. }
  20. }
  21. }