我如何可以设置DataGrid中选定行的颜色 [英] How can I set the color of a selected row in DataGrid
本文介绍了我如何可以设置DataGrid中选定行的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这似乎是一个没有脑子,但我看不出如何做到这一点。
This seems like a no-brainer but i just can't see how to do it.
在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?
试过这个(从Neverminds链接修改)
Tried this (modified from Neverminds link)
<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>
但仍然没有...
But still nothing...
推荐答案
明白了。添加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屋!
查看全文