Export (0) Print
Expand All

TabControl.ContentTemplate Property

Gets or sets the DataTemplate to apply to any TabItem that does not have a ContentTemplate or ContentTemplateSelector property defined.

Namespace:  System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation

public DataTemplate ContentTemplate { get; set; }
<object ContentTemplate="{ResourceExtension TemplateResourceKey}"/>

XAML Values


One of the following: StaticResource, or DynamicResource. See XAML Resources.


The key that identifies the template being requested. The key refers to an existing resource in a ResourceDictionary.


Property element syntax is technically possible, but not recommended. See Inline Styles and Templates.

Property Value

Type: System.Windows.DataTemplate
The DataTemplate to apply to any TabItem that does not have a ContentTemplate or ContentTemplateSelector property defined. The default is null.

Identifier field


Metadata properties set to true


The following example creates two DataTemplate objects. The DataTemplate called contentTemplate is assigned to the ContentTemplate of the TabControl and the DataTemplate called tabItemTemplate is assigned to the ContentTemplate of the second TabItem. All TabItem objects contain the white rectangle defined in contentTemplate, except the second TabItem, which has a gray rectangle, as defined in tabItemTemplate.

<DataTemplate x:Key="contentTemplate">
    <Rectangle Fill="White"/>
    <ContentPresenter Content="{Binding}"/>

<DataTemplate x:Key="tabItemTemplate">
    <Rectangle Fill="Gray"/>
    <ContentPresenter Content="{Binding}"/>


<TabControl Width="250" Height="300" 
            ContentTemplate="{StaticResource contentTemplate}">
  <TabItem Header="One">
    <Ellipse Width="200" Height="200" Fill="#CABCAB"/>
  <TabItem Header="Two"
           ContentTemplate="{StaticResource tabItemTemplate}">
    <Ellipse Width="200" Height="200" Fill="#BADDF00D"/>
  <TabItem Header="Three">
    <Ellipse Width="200" Height="200" Fill="#654321"/>
  <TabItem Header="Four">
    <Ellipse Width="200" Height="200" Fill="#123456"/>
  <TabItem Header="Five">
    <Ellipse Width="200" Height="200" Fill="#F11001"/>

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

© 2014 Microsoft