I am working on a Visual Studio extension and trying to theme a WPF DataGrid to match the Visual Studio light or dark theme. I have managed to get everything working except for the top left corner of the DataGrid.
In Silverlight, this is called the TopLeftCornerHeader, but I cannot figure out how to change the background color in WPF.
So far, I have modified the DataGrid like this,
<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>
I think one of the only ways to be setting for DataGrid
RowHeaderWidth
:
<DataGrid x:Name="dataGrid"
RowHeaderWidth="0"
... />
I tried to set RowHeaderStyle
and RowHeaderTemplate
but they do not affect the area in the upper left corner.
It may also be PART_LeftHeaderGripper
thumb which is located in DataGridColumnHeader
, it is just to the left in the header column:
<Thumb x:Name="PART_LeftHeaderGripper"
HorizontalAlignment="Left"
Style="{StaticResource Style_HeaderGripper}" />