Skip to content

Latest commit

 

History

History
80 lines (59 loc) · 5.24 KB

tabcontrol-styles-and-templates.md

File metadata and controls

80 lines (59 loc) · 5.24 KB
title description ms.date helpviewer_keywords ms.assetid
TabControl Styles and Templates
Learn about the styles and templates for the TabControl control allowing you to modify the default ControlTemplate to give the control a unique appearance.
03/30/2017
ControlTemplate [WPF], TabControl
TabControl [WPF], styles and templates [WPF]
parts [WPF], TabControl
styles [WPF], TabControl
states [WPF], TabControl
templates [WPF], TabControl
f6b19a30-f10e-4fa1-96ce-f17a54092ab6

TabControl Styles and Templates

This topic describes the styles and templates for the xref:System.Windows.Controls.TabControl control. You can modify the default xref:System.Windows.Controls.ControlTemplate to give the control a unique appearance. For more information, see Create a template for a control.

TabControl Parts

The following table lists the named parts for the xref:System.Windows.Controls.TabControl control.

Part Type Description
PART_SelectedContentHost xref:System.Windows.Controls.ContentPresenter The object that shows the content of the currently selected xref:System.Windows.Controls.TabItem.

When you create a xref:System.Windows.Controls.ControlTemplate for a xref:System.Windows.Controls.TabControl, your template might contain an xref:System.Windows.Controls.ItemsPresenter within a xref:System.Windows.Controls.ScrollViewer. (The xref:System.Windows.Controls.ItemsPresenter displays each item in the xref:System.Windows.Controls.TabControl; the xref:System.Windows.Controls.ScrollViewer enables scrolling within the control). If the xref:System.Windows.Controls.ItemsPresenter is not the direct child of the xref:System.Windows.Controls.ScrollViewer, you must give the xref:System.Windows.Controls.ItemsPresenter the name, ItemsPresenter.

TabControl States

The following table lists the visual states for the xref:System.Windows.Controls.TabControl control.

VisualState Name VisualStateGroup Name Description
Normal CommonStates The default state.
Disabled CommonStates The control is disabled.
Valid ValidationStates The control uses the xref:System.Windows.Controls.Validation class and the xref:System.Windows.Controls.Validation.HasError%2A?displayProperty=nameWithType attached property is false.
InvalidFocused ValidationStates The xref:System.Windows.Controls.Validation.HasError%2A?displayProperty=nameWithType attached property is true has the control has focus.
InvalidUnfocused ValidationStates The xref:System.Windows.Controls.Validation.HasError%2A?displayProperty=nameWithType attached property is true has the control does not have focus.

TabItem Parts

The xref:System.Windows.Controls.TabItem control does not have any named parts.

TabItem States

The following table lists the visual states for the xref:System.Windows.Controls.TabItem control.

VisualState Name VisualStateGroup Name Description
Normal CommonStates The default state.
MouseOver CommonStates The mouse pointer is positioned over the control.
Disabled CommonStates The control is disabled.
Focused FocusStates The control has focus.
Unfocused FocusStates The control does not have focus.
Selected SelectionStates The control is selected.
Unselected SelectionStates The control is not selected.
Valid ValidationStates The control uses the xref:System.Windows.Controls.Validation class and the xref:System.Windows.Controls.Validation.HasError%2A?displayProperty=nameWithType attached property is false.
InvalidFocused ValidationStates The xref:System.Windows.Controls.Validation.HasError%2A?displayProperty=nameWithType attached property is true has the control has focus.
InvalidUnfocused ValidationStates The xref:System.Windows.Controls.Validation.HasError%2A?displayProperty=nameWithType attached property is true has the control does not have focus.

TabControl ControlTemplate Example

The following example shows how to define a xref:System.Windows.Controls.ControlTemplate for the xref:System.Windows.Controls.TabControl and xref:System.Windows.Controls.TabItem controls.

[!code-xamlControlTemplateExamples#TabControl]

The preceding example uses one or more of the following resources.

[!code-xamlControlTemplateExamples#Resources]

For the complete sample, see Styling with ControlTemplates Sample.

See also