mvvm 值绑定问题
binging一个1,0 比如1表示OK,0表示NO 用字符串的形式显示在DataGrid中,不知道如何显示,谢谢。不用单选按钮模式,除了新建实体绑定外,有什么比较好的方法 ,谢谢大侠
[解决办法]
IValueConverter实现:
public class CustomerConvert:IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
string num=value.ToString();
switch (num)
{
case "1":
num = "yes";
break;
case "0":
num = "no";
break;
default:
break;
}
return num;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
}
}
<UserControl.Resources>
<bind:CustomerConvert x:Key="convert" />
</UserControl.Resources>
Text="{Binding BindNum, Converter={StaticResource convert}}"