views:

773

answers:

2

Is there an easy way to change header font size without overwriting completely duplicating ColumnHeaderTemplate?

Note: Not sure if it is relevant, but I use an application theme (PresentationFramework.Royale) which provides the ColumnHeaderTemplate.

+2  A: 

If you aren't also applying a style to the Column Headers, you could use that. And even if you are, by setting the BasedOn property on the style you can maintain everything but what you want to change.

<ListView>
 <ListView.View>
  <GridView>
   <GridView.ColumnHeaderContainerStyle>
    <Style>
     <Setter Property="TextElement.FontSize"
       Value="32" />
    </Style>
   </GridView.ColumnHeaderContainerStyle>
   <GridViewColumn Header="Stuff"/>
   <GridViewColumn Header="More Stuff" />
  </GridView>
 </ListView.View>
</ListView>


Edit:
I Haven't used the built in themes before, so I tested this out. The PresentationFramework.Royale theme isn't actually applying a template to the column headers. It is applying a Style which uses a setter to apply the ControlTemplate like recommended.

So, in order to keep the Royale theme on the Column Headers we do need to use the BasedOn property of the Style we created. Here's the updated Style deffinition that will both allow you to modify what you like, and retain the Royale Theme:

<Style TargetType="{x:Type GridViewColumnHeader}" BasedOn="{StaticResource {x:Type GridViewColumnHeader}}">
rmoore
A: 

The GridViewColumnHeader is a content control, so if you set its content to a TextBlock in which the text you want is the proper size, life should be good.

PeterAllenWebb