Export (0) Print
Expand All

TabControl Class

Represents a control that allows visual content to be arranged in a tabular form.

Namespace: System.Windows.Controls
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

[StyleTypedPropertyAttribute(Property="ItemContainerStyle", StyleTargetType=typeof(TabItem))] 
[TemplatePartAttribute(Name="PART_SelectedContentHost", Type=typeof(ContentPresenter))] 
public class TabControl : Selector
/** @attribute StyleTypedPropertyAttribute(Property="ItemContainerStyle", StyleTargetType=System.Windows.Controls.TabItem) */ 
/** @attribute TemplatePartAttribute(Name="PART_SelectedContentHost", Type=System.Windows.Controls.ContentPresenter) */ 
public class TabControl extends Selector
StyleTypedPropertyAttribute(Property="ItemContainerStyle", StyleTargetType=System.Windows.Controls.TabItem) 
TemplatePartAttribute(Name="PART_SelectedContentHost", Type=System.Windows.Controls.ContentPresenter) 
public class TabControl extends Selector
<TabControl>
  Items
</TabControl>

The TabControl is useful for minimizing screen space usage while allowing an application to expose a large amount of data.

Frequently when elements inherit from a base class the properties of the subclassed element have default values different from the same properties on the base class. Sometimes a subclassed element overrides an inherited property's default value. The following table illustrates this for Selector and TabControl.

Property

BaseClass

Default

SubClass

Default

IsSelectionRequired

Selector

false

TabControl

true

ContentModel: A TabControl is an ItemsControl. For more information on the content model for TabControl, see ItemsControl Content Model.

This example shows how to create a TabControl. It uses the Header property to label the tabs.

<TabControl TabStripPlacement="Top" Margin="0, 0, 0, 10">
  <TabItem Name="tabIitemContent" Header="TabItem with Buttons">
    <StackPanel>
      <Button Content="_OK"/>
      <Button Content="_Cancel"/>
    </StackPanel>
  </TabItem>

  <TabItem Name="backgroundcolor" Header="Background">
    <TabItem.Content>Background property information goes here.</TabItem.Content>
  </TabItem>

  <TabItem Name="foregroundcolor" Header="Foreground">
    <TabItem.Content>Foreground property information goes here.</TabItem.Content>
  </TabItem>

  <TabItem Name="bordercolor" Header="BorderColor">
    <TabItem.Content>Border color property information goes here.</TabItem.Content>
  </TabItem>
</TabControl>

tabcon = new System.Windows.Controls.TabControl();
ti1 = new TabItem();
ti1.Header = "Background";
tabcon.Items.Add(ti1);
ti2 = new TabItem();
ti2.Header = "Foreground";
tabcon.Items.Add(ti2);
ti3 = new TabItem();
ti3.Header = "FontFamily";
tabcon.Items.Add(ti3);

cv2.Children.Add(tabcon);

For the complete sample, see TabControl Sample.

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 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

ADD
Show:
© 2014 Microsoft