Reputation: 734
I'd like to implement a 'TabManager' control which can be instantiated much like a Grid in XAML. This looks like a fairly common task, but I couldn't seem to find a tutorial and I still don't want to reinvent the wheel, so I was wondering if anyone here had an example.
I'd want the XAML to generate the control to look something like this:
<TabManager>
<TabManager.TabDefinitions>
<TabDefinition Caption="Tab 1"/>
<TabDefinition Caption="Tab 2"/>
<TabDefinition Caption="Tab 3"/>
</TabManager.TabDefinitions>
<TabPanel TabManager.Tab="0">
<TextBlock Text="foo"/>
</TabPanel>
<TabPanel TabManager.Tab="1">
<TextBlock Text="bar"/>
</TabPanel>
<TabPanel TabManager.Tab="2">
<TextBlock Text="baz"/>
</TabPanel>
</TabManager>
The TabManager will render a few buttons and some elements to contain the TabPanels' children - e.g. place them into a DockPanel or whatever else I choose to do; shouldn't matter.
Upvotes: 0
Views: 179
Reputation: 2374
Have you tried <TabControl>
?
For instance -
<TabControl>
<TabItem Header="Tab1" x:Name="Tab1">
<Grid>
<TextBlock Text="foo"/>
</Grid>
</TabItem>
<TabItem Header="Tab2" x:Name="Tab2">
<Grid>
<TextBlock Text="bar"/>
</Grid>
</TabItem>
<TabItem Header="Tab3" x:Name="Tab3">
<Grid>
<TextBlock Text="baz"/>
</Grid>
</TabItem>
</TabControl>
Upvotes: 2