GridViewColumn.HeaderTemplate Property

Gets or sets the template to use to display the content of the column header.

Namespace: System.Windows.Controls
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace:

public DataTemplate HeaderTemplate { get; set; }
/** @property */
public DataTemplate get_HeaderTemplate ()

/** @property */
public void set_HeaderTemplate (DataTemplate value)

public function get HeaderTemplate () : DataTemplate

public function set HeaderTemplate (value : DataTemplate)

<object HeaderTemplate="{ResourceExtensionTemplateResourceKey}"/>
 ResourceExtension   StaticResource or DynamicResource. StaticResource typically provides better performance.  TemplateResourceKey  An x:Key resource key that refers to a template resource. 

Property Value

A DataTemplate to use to display the column header. The default value is a null reference (Nothing in Visual Basic).

Identifier field


Metadata properties set to true


If both the HeaderTemplateSelector property and the HeaderTemplate property are set, the HeaderTemplate property takes precedence.

After a HeaderTemplate or ColumnHeaderTemplate is specified for a GridViewColumn, it cannot be changed.

You can also define the display of a column header by specifying a ControlTemplate as part of a GridViewColumn.HeaderContainerStyle.

Properties that define the content, layout, and style of a column header are found on many related classes, and some of these properties have functionality that is similar or the same. For more information, see GridView Column Header Styles and Templates Overview.

The following example shows how to specify a template to use to display the header of a GridViewColumn. For the complete sample, see ListView implementing a GridView with Templates.

<DataTemplate x:Key="myHeaderTemplate">
    <TextBlock FontSize="16" Foreground="DarkBlue">

<GridViewColumn Header="Month" Width="80"
      HeaderContainerStyle="{StaticResource myHeaderStyle}"
      HeaderTemplate="{StaticResource myHeaderTemplate}"
      DisplayMemberBinding="{Binding Path=Month}"/>

More Code

How to: Use Templates to Style a ListView That Uses GridView

This example shows how to use the DataTemplate and Style objects to specify the appearance of a ListView control that uses a GridView view mode.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0