Ask Learn
Preview
Please sign in to use this experience.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
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 item that labels the control.
public:
property System::Object ^ Header { System::Object ^ get(); void set(System::Object ^ value); };
[System.ComponentModel.Bindable(true)]
public object Header { get; set; }
[<System.ComponentModel.Bindable(true)>]
member this.Header : obj with get, set
Public Property Header As Object
An object that labels the HeaderedItemsControl. The default is null
. A header can be a string or a UIElement.
The following example shows how to create and use a header template to specify the appearance of the header.
<!--Define a control template for a HeaderedItemsControl-->
<Style TargetType="HeaderedItemsControl">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type HeaderedItemsControl}">
<StackPanel>
<Grid>
<Rectangle Fill="{TemplateBinding Background}"/>
<ContentPresenter ContentSource="Header"/>
</Grid>
<Grid>
<Rectangle Stroke="{TemplateBinding BorderBrush}"/>
<ItemsPresenter Margin="2,0,0,0"/>
</Grid>
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<DataTemplate x:Key="RedHeaderTemplate">
<TextBlock Text="{Binding}" Foreground="Red"
FontSize="16" FontWeight="Bold"
TextWrapping="Wrap"/>
</DataTemplate>
<DataTemplate x:Key="GreenItemTemplate">
<TextBlock Text="{Binding}" Foreground="Green"
FontSize="14" FontWeight="Bold"></TextBlock>
</DataTemplate>
<!--Crate a HeaderedItemControl with a red header and green items.-->
<HeaderedItemsControl Name="hitemsCtrl"
Background="DarkBlue"
BorderBrush="Black"
Header="Header"
HeaderTemplate="{StaticResource RedHeaderTemplate}"
ItemsSource="{Binding Source={StaticResource Numbers}}"
ItemTemplate = "{StaticResource GreenItemTemplate}" />
Because the Header property is of type Object, there are no restrictions on what you can put in the Header. The Header is displayed by a ContentPresenter, which is in the HeaderTemplate of the HeaderedItemsControl. For more information about how the ContentPresenter displays the Header, see ContentPresenter.
<object Header="headerString"/>
<object>
<object.Header>
<UIElement />
</object.Header>
</object>
headerString
The string to use as a heading.
Item | Value |
---|---|
Identifier field | HeaderProperty |
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, 10 |
.NET feedback
.NET is an open source project. Select a link to provide feedback:
Please sign in to use this experience.
Sign in