GridViewColumn.HeaderTemplate Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets the template to use to display the content of the column header.
public:
property System::Windows::DataTemplate ^ HeaderTemplate { System::Windows::DataTemplate ^ get(); void set(System::Windows::DataTemplate ^ value); };
public System.Windows.DataTemplate HeaderTemplate { get; set; }
member this.HeaderTemplate : System.Windows.DataTemplate with get, set
Public Property HeaderTemplate As DataTemplate
Property Value
A DataTemplate to use to display the column header. The default is null
.
Examples
The following example shows how to specify a template to use to display the header of a GridViewColumn.
<DataTemplate x:Key="myHeaderTemplate">
<DockPanel>
<CheckBox/>
<TextBlock FontSize="16" Foreground="DarkBlue">
<TextBlock.Text>
<Binding/>
</TextBlock.Text>
</TextBlock>
</DockPanel>
</DataTemplate>
<GridViewColumn Header="Month" Width="80"
HeaderContainerStyle="{StaticResource myHeaderStyle}"
HeaderTemplate="{StaticResource myHeaderTemplate}"
DisplayMemberBinding="{Binding Path=Month}"/>
Remarks
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.
XAML Attribute Usage
<object HeaderTemplate="{ResourceExtension TemplateResourceKey}"/>
XAML Property Element Usage
XAML Values
ResourceExtension
One of the following: StaticResource
, or DynamicResource
. See XAML Resources.
TemplateResourceKey
The key that identifies the template being requested. The key refers to an existing resource in a ResourceDictionary.
Note
Property element syntax is technically possible, but not recommended. See Inline Styles and Templates. A binding reference using or is also possible, but uncommon.
Dependency Property Information
Identifier field | HeaderTemplateProperty |
Metadata properties set to true |
None |