Export (0) Print
Expand All

GridView.ColumnHeaderContainerStyle Property

Gets or sets the style to apply to column headers.

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 Style ColumnHeaderContainerStyle { get; set; }
<object ColumnHeaderContainerStyle="{ResourceExtension StyleResourceKey}"/>

XAML Values

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.

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.Style
The Style that is used to define the display properties for column headers. The default value is null.

Identifier field

ColumnHeaderContainerStyleProperty

Metadata properties set to true

None

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 Styling and Templating.

The following example shows how to define the ColumnHeaderContainerStyle property.


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



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


.NET Framework

Supported in: 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

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

Community Additions

ADD
Show:
© 2014 Microsoft