【发布时间】:2016-07-05 10:16:14
【问题描述】:
这是我的第一个问题,所以要小心:) 我正在尝试在xaml中绑定属性(a),前景色有效(因此datagrid单元格的参考是正确的),但背景不是,我试图理解为什么,如果我尝试调试我的属性,程序没有进入它......
(a)=
public int CellGiorno1
{
get
{
int a = myfunctionexample(day, Username, month, year);
return a;
//return 0-1-2
}
}
(如果返回的数字为 1,我想要为背景着色的数据网格的列) DataGridTextColumn Header="2" x:Name="HeaderGG1" Binding={Binding Desc_GG1}" CellStyle="{StaticResource CellStyleGiorno}"/>
(the style with the trigger that color the foreground but not the background)
<Style x:Key="CellStyleGiorno" TargetType="DataGridCell">
<Setter Property="Foreground" Value="Red"/>
<Style.Triggers>
<DataTrigger Binding="{Binding CellGiorno1}" Value="1">
<Setter Property="Background" Value="Green"/>
</DataTrigger>
</Style.Triggers>
</Style>
【问题讨论】:
标签: c# wpf xaml triggers styles