HeaderedItemsControl::HeaderTemplate Property
Gets or sets the template used to display the contents of the control's header.
Assembly: PresentationFramework (in PresentationFramework.dll)
public: [BindableAttribute(true)] property DataTemplate^ HeaderTemplate { DataTemplate^ get(); void set(DataTemplate^ value); }
Property Value
Type: System.Windows::DataTemplate^A data template used to display a control's header. The default is null.
To customize the heading of the HeaderedItemsControl, set this property to a DataTemplate. For more information on data templates, see Data Templating Overview.
<object HeaderTemplate="{ResourceExtension TemplateResourceKey}"/>
- ResourceExtension
One of the following: StaticResource, or DynamicResource. See XAML Resources.
- TemplateResourceKey
The key that identifies the template 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. |
Identifier field | |
Metadata properties set to true | None |
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}" />
Available since 3.0
Silverlight
Available since 3.0
Windows Phone Silverlight
Available since 7.0
