Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
TabControl Class
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
TabControl Class

Updated: February 2009

Represents a control that contains multiple items that share the same space on the screen.

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
Visual Basic (Declaration)
<StyleTypedPropertyAttribute(Property := "ItemContainerStyle", StyleTargetType := GetType(TabItem))> _
<TemplatePartAttribute(Name := "PART_SelectedContentHost", Type := GetType(ContentPresenter))> _
Public Class TabControl _
    Inherits Selector
Visual Basic (Usage)
Dim instance As TabControl
C#
[StyleTypedPropertyAttribute(Property = "ItemContainerStyle", StyleTargetType = typeof(TabItem))]
[TemplatePartAttribute(Name = "PART_SelectedContentHost", Type = typeof(ContentPresenter))]
public class TabControl : Selector
Visual C++
[StyleTypedPropertyAttribute(Property = L"ItemContainerStyle", StyleTargetType = typeof(TabItem))]
[TemplatePartAttribute(Name = L"PART_SelectedContentHost", Type = typeof(ContentPresenter))]
public ref class TabControl : public Selector
JScript
public class TabControl extends Selector
XAML Object Element Usage
<TabControl>
  Items
</TabControl>

The TabControl is useful for minimizing screen space usage while allowing an application to expose a large amount of data. A TabControl consists of multiple TabItem objects that share the same screen space. Only one TabItem in a TabControl is visible at a time. When a user selects the tab of a TabItem, the contents of that TabItem become visible and the contents of the other TabItem objects are hidden.

Content Model: TabControl is a ItemsControl. Its content properties are Items and ItemsSource. For more information on the content model for TabControl, see Controls Content Model Overview.

Dependency properties for this control might be set by the control’s default style. If a property is set by a default style, the property might change from its default value when the control appears in the application. The default style is determined by which desktop theme is used when the application is running. For more information, see Themes.

The following example creates a TabControl and binds the TextBlock in the second TabItem to a TextBox in the first TabItem.

XAML
<TabControl>
  <TabItem>
    <TabItem.Header>
      <StackPanel Orientation="Horizontal">
        <Ellipse Width="10" Height="10" Fill="DarkGray"/>
        <TextBlock>Tab 1</TextBlock>
      </StackPanel>
    </TabItem.Header>
    <StackPanel>
      <TextBlock>Enter some text</TextBlock>
      <TextBox Name="textBox1" Width="50"/>
    </StackPanel>
  </TabItem>
  <TabItem Header="Tab 2">
    <!--Bind TextBlock.Text to the TextBox on the first
    TabItem.-->
    <TextBlock Text="{Binding ElementName=textBox1, Path=Text}"/>
  </TabItem>
</TabControl>
System..::.Object
  System.Windows.Threading..::.DispatcherObject
    System.Windows..::.DependencyObject
      System.Windows.Media..::.Visual
        System.Windows..::.UIElement
          System.Windows..::.FrameworkElement
            System.Windows.Controls..::.Control
              System.Windows.Controls..::.ItemsControl
                System.Windows.Controls.Primitives..::.Selector
                  System.Windows.Controls..::.TabControl
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

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

.NET Framework

Supported in: 3.5, 3.0

Date

History

Reason

February 2009

Described how default styles change dependency properties.

Customer feedback.

July 2008

Added new members: ContentStringFormat property, SelectedContentStringFormat property, ContentStringFormatProperty field, SelectedContentStringFormatProperty field.

SP1 feature change.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker