Click here to Skip to main content
13,197,200 members (58,086 online)
Rate this:
Please Sign up or sign in to 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 16-Oct-12 9:18am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.171020.1 | Last Updated 16 Oct 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100