keyle
keyle

Reputation: 2837

GridViewColumnHeader confusion

Why would that work:

<Style x:Key="myHeaderStyle" TargetType="{x:Type GridViewColumnHeader}">
  <Setter Property="Background" Value="LightBlue"/>
</Style>

And not this?

<ListView.View>
     <GridView>
         <GridView.ColumnHeaderContainerStyle>
             <Style>
                <Setter Property="Background" Value="Orange" />
             </Style>
         </GridView.ColumnHeaderContainerStyle>
...

thanks

Upvotes: 1

Views: 643

Answers (1)

Quartermeister
Quartermeister

Reputation: 59149

You need to set the TargetType property on the Style or the parser won't know how to resolve Background:

<ListView.View>
    <GridView>
        <GridView.ColumnHeaderContainerStyle>
            <Style TargetType="GridViewColumnHeader">
                <Setter Property="Background" Value="Orange" />
            </Style>
        </GridView.ColumnHeaderContainerStyle>

It's also possible to qualify the property name in the Setter:

<Setter Property="GridViewColumnHeader.Background" Value="Orange" />

but that syntax is intended for attached properties.

Upvotes: 2

Related Questions