Group Header Styling
The DataGrid provides several approaches to customize its group headers.
Styling Properties
The appearance of the group headers can be changed through the following properties:
-
GroupHeaderStyle
&mdas;Allows you to apply a style to all group headers. TheTargetType
of theStyle
has to be aDataGridGroupHeader
.DataGridGroupHeader Style
GroupHeaderStyleSelector
—Allows you to apply different styles to group headers depending on some custom logic. The following examples demonstrate a possible implementation.-
GroupHeaderTemplate
—Specifies a customDataTemplate
that will be applied to the group header.Custom GroupHeaderTemplate
-
GroupHeaderTemplateSelector
—Applies differentDataTemplates
to the group headers depending on some custom logic. The following examples demonstrate a possible implementation.
You can define whether the group headers will be frozen or scrollable through the
GroupHeaderDisplayMode
property.
Styling The Group Headers
The following examples demonstrate how to populate the DataGrid with data and conditionally apply a style and a DataTemplate
to the group headers. The examples show how to display a different Style
/DataTemplate
for expanded and collapsed groups.