使用WPF DataGrid时如何更改列标题的背景色 [英] How to change column header's background color when using WPF datagrid
本文介绍了使用WPF DataGrid时如何更改列标题的背景色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用WPF数据网格时如何更改列标题的背景颜色?是否需要直接修改xaml?
How to change column header's background color when using WPF datagrid? Need to modify xaml directly?
推荐答案
使用带有针对DataGridColumnHeader的setter的样式:
Use a style with a setter targeted at DataGridColumnHeader:
<DataGrid>
<DataGrid.Resources>
<Style BasedOn="{StaticResource {x:Type DataGridColumnHeader}}" TargetType="{x:Type DataGridColumnHeader}">
<Setter Property="Background" Value="Blue" />
</Style>
</DataGrid.Resources>
</DataGrid>
这篇关于使用WPF DataGrid时如何更改列标题的背景色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文