Changing ColumnHeader color in WPF datagrid

Mar 25, 2010 at 10:57 PM

This is a really trivial task to change the color of the datagrid column headers. I copied this code from another example on the web and can't figure out why it won't work. I assume this <Style> setter changes the style of the datagrid and there is nothing else to be done in the actual datagrid code which occurs further down in the XAML code. Am I correct? If not, what else do I need to do to change the header color?

<Window x:Class="InfoSeeker.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:dg="http://schemas.microsoft.com/wpf/2008/toolkit"
    <Window.Resources>
        <SolidColorBrush x:Key="DataGrid_Style0_Header" Color="AliceBlue" />
        <Style x:Key="ColumnHeaderStyle" TargetType="{x:Type dg:DataGridColumnHeader}">
            <Setter Property="Background" Value="{StaticResource DataGrid_Style0_Header}" />
            <Setter Property="Foreground" Value="White" />
        </Style>
    </Window.Resources>