BoolToStringConvert.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 FurnaceUI.Converter
  8. {
  9. public class BoolToStringConvert : IValueConverter
  10. {
  11. public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  12. {
  13. if (value == null || !(value is bool)) return parameter;
  14. string[] par = ((string)parameter).Split(',');
  15. if (par.Length < 2) return par[0];
  16. if (value is bool)
  17. {
  18. if ((bool)value)
  19. {
  20. return par[0];
  21. }
  22. else
  23. {
  24. return par[1];
  25. }
  26. }
  27. else
  28. {
  29. return parameter;
  30. }
  31. }
  32. public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  33. {
  34. throw new NotImplementedException();
  35. }
  36. }
  37. }