Modifier

GridView.ColumnHeaderTemplate Property

Definition

Gets or sets a template to use to display the column headers.

public:
 property System::Windows::DataTemplate ^ ColumnHeaderTemplate { System::Windows::DataTemplate ^ get(); void set(System::Windows::DataTemplate ^ value); };
public System.Windows.DataTemplate ColumnHeaderTemplate { get; set; }
member this.ColumnHeaderTemplate : System.Windows.DataTemplate with get, set
Public Property ColumnHeaderTemplate As DataTemplate

Property Value

The DataTemplate to use to display the column headers as part of the GridView. The default value is null.

Examples

The following example shows how to set the ColumnHeaderTemplate property.

<DataTemplate x:Key="myHeaderTemplate">
  <DockPanel>
    <CheckBox/>
    <TextBlock FontSize="16" Foreground="DarkBlue">
      <TextBlock.Text>
        <Binding/>
      </TextBlock.Text>
    </TextBlock>
  </DockPanel>
</DataTemplate>
<GridView ColumnHeaderTemplate="{StaticResource myHeaderTemplate}"
          ColumnHeaderContainerStyle="{StaticResource myHeaderStyle}">
  <GridViewColumn Header="Year" Width="80"
        CellTemplate="{StaticResource myCellTemplateYear}"/>
  <GridViewColumn Header="Month" Width="80"
        CellTemplate="{StaticResource myCellTemplateMonth}"/>
  <GridViewColumn Header="Day" Width="80"
        CellTemplate="{StaticResource myCellTemplateDay}"/>
</GridView>

Remarks

If the ColumnHeaderTemplate property and the ColumnHeaderTemplateSelector property are both set, the ColumnHeaderTemplate property takes precedence.

This property represents one of several ways to lay out and style column headers. For more information, see GridView Column Header Styles and Templates Overview.

XAML Attribute Usage

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

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 TemplateBinding or is also possible, but uncommon.

Dependency Property Information

Identifier field ColumnHeaderTemplateProperty
Metadata properties set to true None

Applies to

See also