BoolToTextConverter.cs 895 B

1234567891011121314151617181920212223242526272829
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace TeamAAS_VP.ValueConverter
  7. {
  8. /// <summary>
  9. /// 布尔值到文本转换器
  10. /// </summary>
  11. public class BoolToTextConverter : System.Windows.Data.IValueConverter
  12. {
  13. public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  14. {
  15. if (value is bool boolValue && parameter is string param)
  16. {
  17. var options = param.Split('|');
  18. return boolValue ? options[0] : options[1];
  19. }
  20. return string.Empty;
  21. }
  22. public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  23. {
  24. throw new NotImplementedException();
  25. }
  26. }
  27. }