ContentToBoolConverter.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using System.Globalization;
  2. using System.Windows.Data;
  3. namespace UniformMaterialManagementSystem.Converters
  4. {
  5. public class ContentToBoolConverter: IValueConverter
  6. {
  7. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  8. {
  9. if (value == null || parameter == null)
  10. {
  11. return false;
  12. }
  13. string checkvalue = value.ToString();
  14. string targetvalue = parameter.ToString();
  15. bool r = checkvalue.Equals(targetvalue);
  16. return r;
  17. }
  18. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  19. {
  20. //if (value == null || parameter == null)
  21. //{
  22. // return null;
  23. //}
  24. //if ((bool)value)
  25. //{
  26. // return parameter.ToString();
  27. //}
  28. //return null;
  29. return (bool)value ? parameter : Binding.DoNothing;
  30. }
  31. }
  32. }