GridViewColumn.HeaderContainerStyle Property
In this article
Definition
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 use for the header of the GridViewColumn.
public:
property System::Windows::Style ^ HeaderContainerStyle { System::Windows::Style ^ get(); void set(System::Windows::Style ^ value); };
public System.Windows.Style HeaderContainerStyle { get; set; }
member this.HeaderContainerStyle : System.Windows.Style with get, set
Public Property HeaderContainerStyle As Style
The Style that defines the display properties for the column header. The default is null
.
The following example shows how to define a HeaderContainerStyle that specifies display properties for a column header.
<Style x:Key="myHeaderStyle" TargetType="{x:Type GridViewColumnHeader}">
<Setter Property="Background" Value="LightBlue"/>
</Style>
<GridViewColumn Header="Month" Width="80"
HeaderContainerStyle="{StaticResource myHeaderStyle}"
HeaderTemplate="{StaticResource myHeaderTemplate}"
DisplayMemberBinding="{Binding Path=Month}"/>
The following example shows how to define a HeaderContainerStyle that defines display properties by using a ControlTemplate.
<Style x:Key="myControlTemplateStyle"
TargetType="{x:Type GridViewColumnHeader}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type GridViewColumnHeader}">
<Grid Background="LightBlue">
<DockPanel HorizontalAlignment="Center"
VerticalAlignment="Center">
<CheckBox></CheckBox>
<TextBlock Text="{TemplateBinding Content}"
FontSize="16" Foreground="DarkBlue"/>
</DockPanel>
<Canvas>
<Thumb x:Name="PART_HeaderGripper"
Style="{StaticResource GridViewColumnHeaderGripper}"
Background="Transparent"
/>
</Canvas>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<GridView ColumnHeaderContainerStyle="{StaticResource
myControlTemplateStyle}">
<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 HeaderContainerStyle property and the HeaderTemplate property can together define property values and the visual tree for column header content. The HeaderContainerStyle property can also specify the visual tree by defining a ControlTemplate.
Properties that define the content, layout, and style of a column header are found in many related classes, and some of these properties have functionality that is similar or the same. For more information, see GridView Column Header Styles and Templates Overview.
When you set a style, some restrictions apply. For more information, see the Styling and Templating.
<object HeaderContainerStyle="{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 or is also possible, but uncommon.
Item | Value |
---|---|
Identifier field | HeaderContainerStyleProperty |
Metadata properties set to true |
None |
Applies to
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, 10 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: