Click here to Skip to main content
Sign Up to vote bad
good
See more: WPFC#4.0VS2010MVVM
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:18


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.
  Permalink  
Comments
Milan Mathew - 17 Oct '12 - 4:10
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:29
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
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 8,386
1 OriginalGriff 6,596
2 CPallini 3,533
3 Rohan Leuva 2,703
4 Maciej Los 2,234


Advertise | Privacy | Mobile
Web03 | 2.6.130516.1 | Last Updated 16 Oct 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid