Click here to Skip to main content
11,638,881 members (75,341 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: WPF C#4.0 VS2010 MVVM
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 at 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 at 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
0 Sergey Alexandrovich Kryukov 314
1 Suvendu Shekhar Giri 240
2 stibee 213
3 Mika Wendelius 208
4 Richard Deeming 190
0 OriginalGriff 9,061
1 Sergey Alexandrovich Kryukov 8,773
2 Mika Wendelius 7,027
3 Suvendu Shekhar Giri 2,494
4 F-ES Sitecore 2,438

Advertise | Privacy | Mobile
Web02 | 2.8.150728.1 | Last Updated 16 Oct 2012
Copyright © CodeProject, 1999-2015
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