I am styling a datatable but I can't figure out how to style the top left filed of the datagrid. It is the gray field in this picture:
Do you know how to do it?
Here is my style so far:
<Style TargetType="{x:Type DataGrid}">
<Setter Property="Margin" Value="5" />
<Setter Property="Background">
<Setter.Value>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="White"/>
<GradientStop Color="AliceBlue" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
<Setter Property="RowBackground">
<Setter.Value>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#BAF0FF"/>
<GradientStop Color="PowderBlue" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
<Setter Property="AlternatingRowBackground">
<Setter.Value>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="White"/>
<GradientStop Color="AliceBlue" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
<Setter Property="HorizontalGridLinesBrush" Value="LightGray" />
<Setter Property="VerticalGridLinesBrush" Value="LightGray" />
</Style>
I got an imperfect but working solution.
You can get the "Top left corner" object of the datagrid by VisualTreeHelper. Which is actually a button. I think you know how to do next.
Here is my working code:
From this answer I was able to create this code which correctly sets the style of the button: