Click here to Skip to main content
15,908,842 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everyone,

I am making an application in wpf.what i need is as wpf doesn't have MDI form i decided to make a menu control on top of the screen and decided to have a sub-menu in the side panel. and on click of that sub menus tabbed windows would be added dynamically in tab control in the remaining screen area.

Now on click of top menu control , i dynamically add sub-menus usercontrol in stackpanel.

On that user control which contains sub-menu events i want to call entry user-control window and add it to the tab control window of main screen. I tried implementing ITabbed Interface and implementing "Add Tab" method of that interface but the tab does not appears on the main screen ....

Please suggest and help me out on this.....i am really stuck up..

Thanks & Regards,
Krunal Panchal
Posted

check this out:

Adding TabItem at runtime in a C# WPF application[^]

hope it helps :)
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 5-Mar-12 17:46pm    
Sure, a 5. This is very simple; hard to say what could be a problem.
--SA
Ok, You can bind a collection to the ItemsSource on a TabControl. If you are going to have all tabs based only the same template, then you need to only create a DataTemplate that contains the form you need. There appears to be an article that might help you at Persist the Visual Tree when switching tabs in the WPF TabControl[^]

Hopefully that will help.
 
Share this answer
 
v2
Comments
SteveAdey 5-Mar-12 15:09pm    
Sure there's a clean way, use an ObservableCollection of the items in your View Model and then bind them to the ItemsSource of the TabControl.
Clifford Nelson 5-Mar-12 15:15pm    
You are right, there is an ItemsSource on the TabControl.
Here's a quick demo of the MVVM way to use the TabControl.

http://tap-source.com/mvvm-tabcontrol/[^]

In this scenario, you would just add a new ItemViewModel to the Items collection when you select your menu item.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900