New Window in a TabItem?

Poku picture Poku · Dec 18, 2009 · Viewed 10.4k times · Source

Is it possible to open another Window in a TabControl's TabItem?

The reason I want to do this is that if I have 5 TabItems in my TabControl, the one Window file I'm coding all these TabItems and their associated actions will get very large. So it would be nice if it was possible to to give each TabItem its own Window file.

Or how do you solve the problem where theWindow file controlling the TabControl gets too large?

Answer

Akash Kava picture Akash Kava · Dec 18, 2009
<Window ...
     xmlns:local="clr-namespace:MyNamespace"
     >
     <TabControl>
          <TabItem Header="FirstTab">
               <local:MyFirstTabUserControl/>  
          </TabItem>
          <TabItem Header="SecondTab">
               <local:MySecondTabUserControl/>  
          </TabItem>
          <TabItem Header="ThirdTab">
               <local:MyThirdTabUserControl/>  
          </TabItem>
     </TabControl>
</Window>

Your each TabUserControl is actually simple UserControl, since TabItem can host any control as its own child.