ReverseBoolConverter.cs 644 B

1234567891011121314151617181920212223242526
  1. using System;
  2. using System.Windows.Data;
  3. using System.Globalization;
  4. namespace Compdfkit_Tools.Common
  5. {
  6. [ValueConversion(typeof(bool), typeof(bool))]
  7. public class ReverseBoolConverter:IValueConverter
  8. {
  9. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  10. {
  11. return value != null && (bool)value != true;
  12. }
  13. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  14. {
  15. if (value is bool b)
  16. {
  17. return !b;
  18. }
  19. return value;
  20. }
  21. }
  22. }