HeaderedContentControl Content Model Overview
This content model overview describes the supported content for a HeaderedContentControl. The TabItem class is a type of HeaderedContentControl.
A HeaderedContentControl has two content properties:
This topic contains the following sections.
- Using the Header Property
- Using the Content Property
- Types that Share this Content Model
- Types that Can Contain HeaderedContentControl Objects
- Related Topics
Using the Header Property
A HeaderedContentControl's Header content is typically used to label or identify the control's primary contents. For example, a TabItem's header is the content that appears on the tab, while its primary content appears in the panel. In the following illustration, "Font", "Character Spacing", and "Text Effects" are examples of header content.
The Header property supports both text and UIElement content.
Adding Text Content
The Header property accepts text. The following example shows how to add text content to a control's header.
<TabItem Header="Some Header Content">
</TabItem>
TabItem myTabItem = new TabItem();
myTabItem.Header = "Some Header Content";
Adding UIElement Content
The Header property can also accept a single UIElement as its content. Examples of UIElements include Image, StackPanel, and Rectangle. The following example shows how to add a UIElement to a control's header.
<TabItem>
<TabItem.Header>
<Image Source="Images\fish.png" Width="16" Height="16"/>
</TabItem.Header>
</TabItem>
TabItem myTabItem2 = new TabItem();
Image myImage = new Image();
myImage.Width = 16;
myImage.Height = 16;
BitmapImage myBitmapImage = new BitmapImage();
myBitmapImage.BeginInit();
myBitmapImage.UriSource = new Uri(@"pack://application:,,,/images/fish.png");
myBitmapImage.EndInit();
myImage.Source = myBitmapImage;
myTabItem2.Header = myImage;
There are a wide variety of UIElement types that can be used as header content, including those that belong to the following type families.
Using the Content Property
The content of a HeaderedContentControl is typically used to contain the control's primary contents. For example, the content of a TabItem is what appears when the TabItem is selected.
The Content property which the HeaderedContentControl inherits from ContentControl supports both text and UIElement content.
Adding Text Content
The Content property accepts text. The following example shows how to add text content to a control.
<TabItem Header="My Header">
Some text content.
</TabItem>
TabItem myTabItem3 = new TabItem();
myTabItem3.Header = "MyHeader";
myTabItem3.Content = "Some text content";
Adding UIElement Content
The Content property can also accept a single UIElement as its content. Examples of such elements include Image, StackPanel, and Rectangle. The following example shows how to add a UIElement to a control.
<TabItem Header="MyHeader">
<Image Source="Images\fish.png" Width="16" Height="16"/>
</TabItem>
TabItem myTabItem4 = new TabItem();
Image myImage2 = new Image();
myImage2.Width = 16;
myImage2.Height = 16;
BitmapImage myBitmapImage2 = new BitmapImage();
myBitmapImage2.BeginInit();
myBitmapImage2.UriSource =
new Uri(@"pack://application:,,,/images/fish.png");
myBitmapImage2.EndInit();
myImage2.Source = myBitmapImage2;
myTabItem4.Header = "MyHeader";
myTabItem4.Content = myImage2;
For more information about Content, see the ContentControl Content Model Overview.
Types that Share this Content Model
The following classes inherit from the HeaderedContentControl class and may be used to display the content described in this overview.
Note that this list only includes non-abstract types distributed with the Windows SDK. You may use other types that inherit from HeaderedContentControl.
Types that Can Contain HeaderedContentControl Objects
The HeaderedContentControl class can be used as content for the following types.
Note that this list only includes types distributed with Windows SDK.