3
我试图使细胞加粗或正常的,如果项目新/老里面的DataGrid,但偶然埃罗..绑定DataGrid的fontWeight设置属性值转换
貌似这里描述了我的问题:Why can I not bind the Visiblity of a DataGridTemplateColumn in Silverlight 4?
我“M收到以下错误:
Object of type 'System.Windows.Data.Binding' cannot be converted to type 'System.Windows.FontWeight'.
我的XAML看起来像这样:
<sdk:DataGridTextColumn Header="Subject" Binding="{Binding Subject}" CanUserReorder="True" CanUserResize="True" CanUserSort="True" Width="Auto" FontWeight="{Binding IsNew, Converter={StaticResource BoolToFontWeightConverter}}" />
我的问题是有任何解决方法让这个工作?我甚至不使用模板列,它是纯文本列..
public class BoolToFontWeightConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return ((bool)value) ? FontWeights.Bold : FontWeights.Normal;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return (FontWeight)value == FontWeights.Bold;
}
}
是返回类型的转换器等于fontWeight类型? –
转换器代码永远不会被打 - 我添加了代码 – katit
不幸的是,['FontWeight'](http://msdn.microsoft.com/en-us/library/system.windows.controls.datagridtextcolumn.fontweight(v = VS.95 ).aspx)不是依赖项属性 –