Table of Contents
HeaderTemplate Property

Gets or sets the HeaderTemplate property. This is a dependency property.

Syntax
 public DataTemplate HeaderTemplate { get; set; }

Property Value

The default value is null.

Remarks

The HeaderTemplate property represents a shortcut for not individually defining the HeaderTemplate of each TabItem contained in this TabControl instance.

The following example uses an array of color strings as the items source of the TabControl, and then the HeaderTemplate property is used to provide a common template with color preview at the header.

XAML
<Window x:Class="Test.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:eo="http://schemas.essentialobjects.com/wpf/"
        xmlns:sys="clr-namespace:System;assembly=mscorlib"
        Title="MainWindow" Height="350" Width="450">
    <Grid>
        <Grid.Resources>
            <x:Array x:Key="Themes" Type="sys:String">
                <sys:String>Blue</sys:String>
                <sys:String>Green</sys:String>
                <sys:String>Silver</sys:String>
            </x:Array>
        </Grid.Resources>

        <eo:TabControl ItemsSource="{StaticResource Themes}">
            <eo:TabControl.HeaderTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <Rectangle Width="22" Height="22" Fill="{Binding}" Margin="0,0,6,0" />
                        <Label Content="{Binding}" ContentStringFormat="{}{0} Theme" VerticalAlignment="Center" />
                    </StackPanel>
                </DataTemplate>
            </eo:TabControl.HeaderTemplate>
        </eo:TabControl>
    </Grid>
</Window>

The following image shows the result:

See Also