【发布时间】:2011-04-28 02:16:27
【问题描述】:
我正在尝试绑定一个整数属性:
<RadioButton Content="None"
IsChecked="{Binding MyProperty,
Converter={StaticResource IntToBoolConverter},
ConverterParameter=0}" />
我的转换器是:
[ValueConversion(typeof(int), typeof(bool))]
public class IntToBoolConverter : IValueConverter
{
public object Convert(object value, Type t, object parameter, CultureInfo culture)
{
return value.Equals(parameter);
}
public object ConvertBack(object value, Type t, object parameter, CultureInfo culture)
{
return value.Equals(false) ? DependencyProperty.UnsetValue : parameter;
}
}
问题是当我的转换器被调用时,参数是字符串。我需要它是一个整数。我当然可以解析字符串,但我必须这样做吗?
感谢您的帮助 康斯坦丁
【问题讨论】:
-
有谁知道如何在 Windows Phone 平台上实现这一点,我们的绑定语法略有不同? {Binding PROPERTY, Converter={StaticResource MYCONVERTER}, ConverterParameter=INT_VAL} 在此示例中 INT_VAL 将作为字符串传递
标签: wpf binding ivalueconverter