GridView.ColumnHeaderContainerStyle Property

Gets or sets the style to apply to column headers.

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

public Style ColumnHeaderContainerStyle { get; set; }
/** @property */
public Style get_ColumnHeaderContainerStyle ()

/** @property */
public void set_ColumnHeaderContainerStyle (Style value)

public function get ColumnHeaderContainerStyle () : Style

public function set ColumnHeaderContainerStyle (value : Style)

<object ColumnHeaderContainerStyle="{ResourceExtension StyleResourceKey}"/>
 ResourceExtension  One of the following: StaticResource, or DynamicResource. See Resources Overview.  StyleResourceKey  The key that identifies the style being requested. The key refers to an existing resource in a ResourceDictionary. 

Property Value

The Style that is used to define the display properties for column headers. The default value is a null reference (Nothing in Visual Basic).

Identifier field


Metadata properties set to true


The ColumnHeaderContainerStyle property and the ColumnHeaderTemplate property are both used to define the visual tree for the GridViewColumnHeader objects that represent the column headers in a GridView. The ColumnHeaderContainerStyle property can also define column header content when a ColumnHeaderTemplate is not by specified by defining a ControlTemplate for the GridViewColumnHeader object.

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.

When you set styles, there are some restrictions. For more information, see Styles Overview.

The following example shows how to define the ColumnHeaderContainerStyle property. For the complete sample, see ListView implementing a GridView with Templates.

<Style x:Key="myHeaderStyle" TargetType="{x:Type GridViewColumnHeader}">
  <Setter Property="Background" Value="LightBlue"/>

<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}"/>

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

Community Additions