BoolConverter.cs 896 B

123456789101112131415161718192021222324252627282930313233
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows.Data;
  6. namespace Aitex.UI.RecipeEditor
  7. {
  8. public class BoolConverter : IValueConverter
  9. {
  10. public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  11. {
  12. try
  13. {
  14. string v = (string)value;
  15. if (String.Compare(v, "true", true) == 0)
  16. return true;
  17. return false;
  18. }
  19. catch (Exception ex)
  20. {
  21. System.Diagnostics.Debug.WriteLine(ex.Message);
  22. }
  23. return false;
  24. }
  25. public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  26. {
  27. return value.ToString();
  28. }
  29. }
  30. }