Export (0) Print
Expand All

GridView.ColumnHeaderTemplate Property

Gets or sets a template to use to display the column headers. This is a dependency property.

Namespace:  System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation

public DataTemplate ColumnHeaderTemplate { get; set; }
<object>
  <object.ColumnHeaderTemplate>
    <DataTemplate .../>
  </object.ColumnHeaderTemplate>
</object>
<object ColumnHeaderTemplate="{ResourceExtension TemplateResourceKey}"/>

XAML Values

ResourceExtension

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

TemplateResourceKey

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

NoteNote:

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

Property Value

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

Identifier field

ColumnHeaderTemplateProperty

Metadata properties set to true

None

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.

The following example shows how to set the ColumnHeaderTemplate property. For the complete sample, see ListView That Uses a GridView with Templates Sample.

<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>

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0

Community Additions

ADD
Show:
© 2014 Microsoft