views:

175

answers:

1

I am trying to affect the background pattern on a DataGrid in Silverlight 4. I have the following style:

<Style x:Key="DashboardGridHeaderStyle"
       TargetType="primitives:DataGridColumnHeader">
    <Setter Property="FontSize"
            Value="14" />
    <Setter Property="FontWeight"
            Value="Bold" />
    <Setter Property="Foreground"
            Value="{StaticResource xrxGray_I}" />
    <Setter Property="Background"
            Value="{StaticResource xrxGray_B}" />
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate>
                <Grid Height="50" Width="100">
                    <TextBlock Text="{TemplateBinding Header}" />
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

This causes an exception when it is applied. This is caused by the Template setter. Does anyone know how to change the background of the column header (I want a solid color instead of the default gradient)?

Thanks for any help.

+1  A: 

Your ControlTemplate element is missing the TargetType property it should like this:-

 <ControlTemplate TargetType="primitives:DataGridColumnHeader">
AnthonyWJones
That did the trick, but the one other change that I needed to make was to change the "Text="{TemplateBinding Header}"" to "Text="{TemplateBinding Content}"" Thanks for your help.
Sako73