InvertBooleanConverter.cs 915 B

1234567891011121314151617181920212223242526272829
  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. namespace TeamAAS_VP.ValueConverter
  8. {
  9. public class InvertBooleanConverter:IValueConverter
  10. {
  11. public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  12. {
  13. if (value is bool booleanValue)
  14. {
  15. return !booleanValue;
  16. }
  17. return value; // Return the original value if it's not a boolean
  18. }
  19. public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  20. {
  21. if (value is bool booleanValue)
  22. {
  23. return !booleanValue;
  24. }
  25. return value; // Return the original value if it's not a boolean
  26. }
  27. }
  28. }