How to: Create a TabControl

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

Example

<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);
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.

See Also

Tasks

How to: Position Tabs on a TabControl

Reference

TabControl

Concepts

TabControl Overview