0

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.

3
  • Are you looking to create User control ? [link] WPF User Control codeproject.com/Articles/32825/…
    – Habib
    May 16, 2012 at 8:53
  • I'm more likely to derive from Panel, like Grid does. The main point of my question is how to support multiple children in the TabManager class.
    – Zak
    May 16, 2012 at 9:02
  • So basically you want the TabManager to show the Tabs like a Grid layout?? But you only want the Horizontal line at the top so it looks like Tabs?? But the TabControl already has a similar functionality.
    – ArchAngel
    Jun 10, 2016 at 10:53

1 Answer 1

2

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>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.