【在线等】silverlight Binding 自己定义问题
Content="{Binding ProductName}"这种写法是绑定数据源Item的ProductName属性,我现在这里想绑定数据源Item这个对象怎么写?
Tag="{Binding Source={StaticResource DataContextProxy}}" 貌似不行?
如何实现这样的效果, Content="{Binding ProductName} == “衣服”?“是”:“否”"
谢谢大虾~
[解决办法]
cs:
public class lengthconverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return value.ToString()=="衣服"?"是":"否";
}
public object ConvertBack(object value, Type targetType,
object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
xaml:
xmlns:con="clr-namespace:你的类名;"
<UserControl.Resources >
<con:lengthconverter x:Key="XBConvert" />
</UserControl.Resources>
Content="{Binding ProductName,Converter={StaticResource XBConvert}}"