如何在 DataGrid 中设置选定行的颜色 [英] How can I set the color of a selected row in DataGrid
本文介绍了如何在 DataGrid 中设置选定行的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
DataGrid 中选定行的默认背景颜色太深了,我看不懂.无论如何都要覆盖它吗?
The default background color of a selected row in DataGrid is so dark that I can't read it. Is there anyway of overriding it?
试过了
<dg:DataGrid.RowStyle>
<Style TargetType="{x:Type dg:DataGridRow}">
<Style.Triggers>
<Trigger Property="IsSelected" Value="True" >
<Setter Property="Background" Value="Gainsboro" />
</Trigger>
</Style.Triggers>
</Style>
</dg:DataGrid.RowStyle>
但还是没有...
推荐答案
明白了.在 DataGrid.Resources 部分中添加以下内容:
Got it. Add the following within the DataGrid.Resources section:
<DataGrid.Resources>
<Style TargetType="{x:Type dg:DataGridCell}">
<Style.Triggers>
<Trigger Property="dg:DataGridCell.IsSelected" Value="True">
<Setter Property="Background" Value="#CCDAFF" />
</Trigger>
</Style.Triggers>
</Style>
</DataGrid.Resources>
这篇关于如何在 DataGrid 中设置选定行的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文