Click here to Skip to main content
15,884,838 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
I need to place Tabcontrol and need to stick on MVVM pattern. however I am unable to do that without writing code in codebehind. As of now I have one default tab and subsequent tab contents are dynamic
Posted

1 solution

Definately, in fact it is quite easy. Here is an example: MVVM TabControl[^]. Any WPF control that has an ItemsSource should be easy to use with MVVM.
 
Share this answer
 
Comments
Milan Mathew 17-Oct-12 4:10am    
In VS2010 there is no direct option to Add a tabcontrol (can add tabconrol directly but if we want to add additional tabs programmatically) without placing code in your codebehind. Which basically breaks the MVVM pattern principles.
So looking for a solution to add a new tab programmatically without adding code in codebehind.
Clifford Nelson 17-Oct-12 12:29pm    
The WPF TabControl has an ItemsControl DependencyProperty, which allows you to have a collection of ViewModels that can control the tabs. Now you want to have different content in the Tabs which can be handled with a ValueConverter using the ViewModel type to decide which usercontrol to display in the tab. Please note that the

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