DataGrid行的常规文本颜色?

问题描述 投票:7回答:1

我有一个绑定到数据库表的数据网格。我需要将行的前色更改为蓝色,具体取决于其一列中是否有值。有办法吗?我尝试了IValueConverter,但我想一次只能将其用于一个单元格。

wpf datagrid row
1个回答
24
投票
<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>
© www.soinside.com 2019 - 2024. All rights reserved.