How to change column header's background color when using WPF datagrid

user496949 picture user496949 · Dec 20, 2010 · Viewed 64.3k times · Source

How to change column header's background color when using WPF datagrid? Need to modify xaml directly?

Answer

Greg Sansom picture Greg Sansom · Dec 20, 2010

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>