The Windows Presentation Foundation (WPF) TabControl class contains multiple tab items that share the same space on the screen. You can add tab items to a TabControl in the WPF Designer. This topic discusses three ways that you can add tab items to a TabControl.
1. XAML editor.
2. Designer editor.
3. Collection editor.
XAML Editor
You can add manually tab items in a TabControl by tying in the XAML editor.
Steps for adding tab items to a TabControl by using the XAML editor
1. In the XAML editor, locate a TabControl element.
2. Add a TabItem element as a child of the TabControl element. The code should resemble the following:
<TabControl Name="tabControl1">
<TabItem Header="tabItem1" />
</TabControl>
Designer editor.
You can add a tab item to a TabControl by right-clicking the design surface.
Steps for adding tab items to a TabControl by using the designer
1. In the WPF Designer, select a TabControl.
2. In the upper part of the TabControl, right-click a TabItem.
3. Select Add Tab from the context menu.
4. A new TabItem is added to the TabControl.
Collection Editor
You can also add tab items to a TabControl by using the collection editor. When you use the collection editor to configure tab items, Design view and XAML view are updated automatically.
Steps for adding tab items to a TabControl by using the collection editor
1. In the WPF Designer, select a TabControl.
2. In the Properties window, locate the Items property, and click the ellipsis button in the property value column.
3. The Collection Editor Dialog box appears.
4. Click Add to add a new tab item.
5. (Optional) Set the properties of the tab item.
6. (Optional) Repeat steps 3 and 4 to add more tab items.
7. Click OK to close the Collection Editor and return to the WPF Designer.
Leave Comment