我正在研究Visual Studio擴展,並嘗試使用WPF DataGrid來匹配Visual Studio光照或黑暗主題。除了DataGrid的左上角之外,我已經設法讓所有的東西都能正常工作。更改WPF DataGrid左上角標題的背景顏色
在Silverlight中,這就是所謂的TopLeftCornerHeader,但我無法弄清楚如何改變WPF的背景色。
到目前爲止,我已經修改了DataGrid的這個樣子,
<DataGrid
Background="{DynamicResource {x:Static wpf:Theme.BackgroundKey}}"
Foreground="{DynamicResource {x:Static wpf:Theme.ForegroundKey}}"
RowBackground="{DynamicResource {x:Static wpf:Theme.BackgroundKey}}"
AlternatingRowBackground="{DynamicResource {x:Static wpf:Theme.BackgroundAccentKey}}"
HorizontalGridLinesBrush="{DynamicResource {x:Static wpf:Theme.ControlBorderKey}}"
VerticalGridLinesBrush="{DynamicResource {x:Static wpf:Theme.ControlBorderKey}}"
BorderBrush="{DynamicResource {x:Static wpf:Theme.ControlBorderKey}}" >
<DataGrid.ColumnHeaderStyle>
<Style TargetType="DataGridColumnHeader">
<Setter Property="Background" Value="{DynamicResource {x:Static wpf:Theme.BackgroundKey}}" />
</Style>
</DataGrid.ColumnHeaderStyle>
請參閱本http://stackoverflow.com/a/30099602/579817或者這個http://stackoverflow.com/a/25143513/579817回答解決方案,如果你需要行標題是可見的。 – Gman