HeaderTemplate Property

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)

public DataTemplate HeaderTemplate { get; set; }

Property Value

Type: System.Windows.DataTemplate

A DataTemplate to use to display the column header. The default is null.

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.

<object HeaderTemplate="{ResourceExtension TemplateResourceKey}"/>


One of the following: StaticResource, or DynamicResource. See XAML Resources.


The key that identifies the template being requested. The key refers to an existing resource in a ResourceDictionary.


Property element syntax is technically possible, but not recommended. See Inline Styles and Templates. A binding reference using or is also possible, but uncommon.

Identifier field


Metadata properties set to true


The following example shows how to specify a template to use to display the header of a GridViewColumn.

<DataTemplate x:Key="myHeaderTemplate">
    <TextBlock FontSize="16" Foreground="DarkBlue">
<GridViewColumn Header="Month" Width="80"
      HeaderContainerStyle="{StaticResource myHeaderStyle}"
      HeaderTemplate="{StaticResource myHeaderTemplate}"
      DisplayMemberBinding="{Binding Path=Month}"/>

.NET Framework
Available since 3.0
Return to top
© 2015 Microsoft