GridView.ColumnHeaderContainerStyle Property
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets the style to apply to column headers.
public:
property System::Windows::Style ^ ColumnHeaderContainerStyle { System::Windows::Style ^ get(); void set(System::Windows::Style ^ value); };
public System.Windows.Style ColumnHeaderContainerStyle { get; set; }
member this.ColumnHeaderContainerStyle : System.Windows.Style with get, set
Public Property ColumnHeaderContainerStyle As Style
The Style that is used to define the display properties for column headers. The default value is null
.
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>
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.
<object ColumnHeaderContainerStyle="{ResourceExtension StyleResourceKey}"/>
ResourceExtension
One of the following: StaticResource
, or DynamicResource
. See XAML Resources.
StyleResourceKey
The key that identifies the style 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.
Identifier field | ColumnHeaderContainerStyleProperty |
Metadata properties set to true |
None |
Product | Versions |
---|---|
.NET Framework | 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: