SubtractConverter.cs 704 B

12345678910111213141516171819202122
  1. using System;
  2. using System.Globalization;
  3. using System.Windows.Data;
  4. namespace SWRIS.Converters
  5. {
  6. public class SubtractConverter : IValueConverter
  7. {
  8. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  9. {
  10. if (value is double height && parameter is string param)
  11. {
  12. if (double.TryParse(param, out double subtract))
  13. return Math.Max(0, height - subtract);
  14. }
  15. return 200; // 默认值
  16. }
  17. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  18. => throw new NotImplementedException();
  19. }
  20. }