HeaderTemplate Property

GroupStyle.HeaderTemplate Property


Gets or sets the template that is used to display the group header.

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

public DataTemplate HeaderTemplate { get; set; }

Property Value

Type: System.Windows.DataTemplate

A DataTemplate object that is used to display the group header. The default is null.

The following examples show an ItemsControl that is bound to an XmlDataProvider and the code-behind content that contains the logic to add and remove grouping. When the check box is checked, the content of the ItemsControl is grouped by the Type attribute.

Each group is of type CollectionViewGroup. The GroupStyle HeaderTemplate is specified so that it appears as a TextBlock that displays the Name of each the group. In this case, the Name is either Work or Home.

The following example shows how to use the HeaderTemplate property:

The following is the definition of the groupingHeaderTemplateDataTemplate:

For the complete sample, see Data Binding Demo.

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