转换器 IValueConverter
程序员文章站
2022-06-07 10:52:59
...
public class WidthConverter : IValueConverter{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value != null)
{
double num = System.Convert.ToInt32(value);
if (num != 0)
{
return (double)(num - 40);
}
return 0d;
}
return null;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return null;
}
}
WidthConverter是对IValueConverter接口的两个方法的实现