using System; using System.Globalization; using System.Windows.Data; namespace SWRIS.Converters { public class SubtractConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value is double height && parameter is string param) { if (double.TryParse(param, out double subtract)) return Math.Max(0, height - subtract); } return 200; // 默认值 } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException(); } }