This documentation is archived and is not being maintained.

GridView.ColumnHeaderTemplate Property

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

Namespace: System.Windows.Controls
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

public DataTemplate ColumnHeaderTemplate { get; set; }
/** @property */
public DataTemplate get_ColumnHeaderTemplate ()

/** @property */
public void set_ColumnHeaderTemplate (DataTemplate value)

public function get ColumnHeaderTemplate () : DataTemplate

public function set ColumnHeaderTemplate (value : DataTemplate)

<object>
  <object.ColumnHeaderTemplate>
    <DataTemplate .../>
  </object.ColumnHeaderTemplate>
</object>
<object ColumnHeaderTemplate="{ResourceExtensionTemplateResourceKey}"/>

 ResourceExtension   StaticResource or DynamicResource. StaticResource typically provides better performance.  TemplateResourceKey  An x:Key resource key that refers to a template resource. 

Property Value

The DataTemplate to use to display the column headers as part of the GridView. The default value is a null reference (Nothing in Visual Basic).

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 implementing a GridView with Templates.

<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 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0
Show: