Click here to Skip to main content
Rate this: bad
good
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 10:18am

1 solution

Rate this: bad
good
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.
  Permalink  
Comments
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 OriginalGriff 381
1 Sergey Alexandrovich Kryukov 245
2 Marcin Kozub 225
3 Praneet Nadkar 217
4 /\jmot 189
0 OriginalGriff 8,284
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,614
3 Maciej Los 4,989
4 Manas Bhardwaj 4,986


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