GridViewColumnHeader confusion
Why would that work:
<Style x:Key="myHeaderStyle" TargetType="{x:Type GridViewColumnHeader}">
<Setter Property="Background" Value="LightBlue"/>
</Style>
And not this?
<ListV开发者_运维知识库iew.View>
<GridView>
<GridView.ColumnHeaderContainerStyle>
<Style>
<Setter Property="Background" Value="Orange" />
</Style>
</GridView.ColumnHeaderContainerStyle>
...
thanks
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.
精彩评论