我試圖改變一個DataGridTextColumn的顏色。如何設置DataGridTextColumn文本顏色?
下面是我在做什麼:
<DataGridTextColumn
Header="Status"
Binding="{Binding IsActive,
Converter= {StaticResource BoolToStatusConverter}}"
Foreground="{Binding Path=IsActive,
Converter={StaticResource BoolToColorConverter}}"/>
文本設置正確,但顏色不會改變,我得到以下錯誤:
System.Windows.Data Error: 2 : Cannot find governing FrameworkElement or
FrameworkContentElement for target element. BindingExpression:Path=IsActive;
DataItem=null; target element is 'DataGridTextColumn' (HashCode=40349079); target
property is 'Foreground' (type 'Brush')
我應該怎麼辦爲了這個工作?
您是否打算爲整列或單個細胞設置背景? – Phil
我想爲個別單元格設置FOREGROUND –