DataGridColumnHeader - Style does not work

Nov 1, 2008 at 12:40 PM
Hi devteam,

in the v2 of DataGrid, the DataGridColumnHeader seems to be ignored. I think, in v1, this worked correct :-(
Here the sample Code, what goes wrong?

<Window x:Class="Test_Style_DataGridColumnHeader.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="300" Width="300" xmlns:my="http://schemas.microsoft.com/wpf/2008/toolkit">
    <Window.Resources>
        <Style x:Key="defaultColumnHeaderStyle" TargetType="{x:Type my:DataGridColumnHeader}">
            <Setter Property="Background" Value="Red" />
        </Style>
    </Window.Resources>

    <Grid>
        <my:DataGrid Margin="0,0,0,62" Name="dataGrid1">
            <my:DataGrid.Columns>
                <my:DataGridTextColumn Header="Header" />
            </my:DataGrid.Columns>
        </my:DataGrid>
    </Grid>
</Window>

beste regards,
-christoph
Coordinator
Nov 1, 2008 at 3:00 PM
You need to actually set the style resource on the DataGrid or remove the key so it can be an implicit style.
Nov 2, 2008 at 9:55 AM
Edited Nov 2, 2008 at 9:56 AM
remove the key
This is the solution, thank you!

-christoph