我有一个绑定到数据库表的datagrid。我需要将行的前景颜色更改为蓝色,具体取决于其中一列中的值。有没有办法可以做到这一点?我尝试过IValueConverter,但我认为我一次只能将它用于一个单元格。
答案 0 :(得分:22)
<DataGrid>
<DataGrid.CellStyle>
<Style TargetType="{x:Type DataGridCell}">
<Style.Triggers>
<DataTrigger Binding="{Binding SomeProperty}" Value="SomeValue" >
<Setter Property="Foreground" Value="Blue" />
</DataTrigger>
</Style.Triggers>
</Style>
</DataGrid.CellStyle>
</DataGrid>