New window in TabItem?

Can I open another one Windowin TabControl TabItem?

The reason I want to do this is because if I have 5 TabItemin my TabControl, one Window file that I encode all of these TabItemand their related actions will be very large. Therefore, it would be nice to give everyone TabItemtheir own Windowfile.

Or how do you solve the problem when the file Windowmanaging TabControlbecomes too large?

+3
source share
5 answers

You have several options:

  • , , . , .
  • ( XAML ) . - .
  • . , , t XAML. .cs , . ( : -))
+4
<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>

TabUserControl UserControl, TabItem .

+7

UserControl TabItem.

+2

TabItem

ex: [WindowType - ]

WindowsType oWindow = new WindowType();
TabItem oTab = new TabItem();
oTab.Content = oWindow.Content;
+1

UserControl, .

But you can also use the Page control. Each β€œwindow” will be a page, and the tab will have a NavigationControl. I have used this approach before and it works well. I prefer the UserControl route, but both are valid.

0
source

Source: https://habr.com/ru/post/1726033/


All Articles