BooleanToRadioButtonConverter.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. namespace GDNXFD.Alert.Config.Converters
  2. {
  3. using System;
  4. using System.Windows;
  5. using System.Windows.Data;
  6. /// <summary>
  7. /// enum to bool converter
  8. /// </summary>
  9. public class BooleanToRadioButtonConverter : IValueConverter
  10. {
  11. /// <summary>
  12. /// Convert a travel type to bool.
  13. /// </summary>
  14. /// <param name="value"></param>
  15. /// <param name="targetType"></param>
  16. /// <param name="parameter"></param>
  17. /// <param name="culture"></param>
  18. /// <returns></returns>
  19. public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  20. {
  21. if (value is bool)
  22. {
  23. return !(bool)value;
  24. }
  25. return value;
  26. }
  27. /// <summary>
  28. /// Convert back
  29. /// </summary>
  30. /// <param name="value"></param>
  31. /// <param name="targetType"></param>
  32. /// <param name="parameter"></param>
  33. /// <param name="culture"></param>
  34. /// <returns></returns>
  35. public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  36. {
  37. if (value is bool)
  38. {
  39. return !(bool)value;
  40. }
  41. return value;
  42. }
  43. }
  44. }