开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜