Split or stacked tab content

Topics: Prism v2 - WPF 3.5
Nov 2, 2009 at 5:17 PM


In a Prism v2 WPF app I've currently assigned the region name maincontentregion to a tab control.  I've added 4 modules (boy, girl, dog, cat) each with their own view and viewmodel with observationcollection containing many boys, girls, dogs, cats, etc.  Disclaimer: these aren't the real domains.

Each module adds their view to the MainContentRegion via calls to the regionManager.AddToRegion(..., myListViewOfDogs) etc.  I end up with a tabbed view with 4 tab items one for each view/module.

We have now decided that we would like to see the boys and girls side by side in the same tab item while maintaining low coupling (ignorance) between boy and girl modules.  There would now be only 3 tab items with boys and girls in one, while dogs and cats live in their own separate tab item. 

What's the best way (low time, single developer, good quality) of implementing this? 

Perhaps I shouldn't be jamming this in a tab control?  The customer will typically be monitoring near real time updates to the boy girl collections and will occaisonally click to the other lists.



Nov 2, 2009 at 5:29 PM

If you know ahead of time how many tabs you will have, you can create the tabs and place a region on each tab (two on the first tab if you like).


Nov 2, 2009 at 6:33 PM

I have swung three times and missed.

1.  To my existing TabControl (which was named MainContentRegion) I added a TabItem with the region name of JointRegion.  I modified both modules to add to the JointRegion vice the MainContentRegion.  Only one of the modules has their view displayed.  Sorta makes I think, one module gets initialized first so its view gets to the region first (debugger supports this theory).

2.  I add a stack panel to the TabItem and try and give it the name JointRegion.  Ooops, stackpanel is not an ItemsControl, ContentControl, nor a Selector.  Exception thrown trying to name the element.

3.  I re-read the post and note that you say "two on the first tab".  Here I assume you meant add a 2nd named region to the tab item.  Nope doesn't support multiple attributes.

It feels like I need a stack panel in on of the tabitems so that both views can be displayed simultaneously. 


Nov 2, 2009 at 7:09 PM

You can add a stack panel orientation horizontal to the tab item you added (remove the region attribute from this tab item), and add two user controls to the stack pannel and add a region attribute to each.

You are right that ContentControl derrived classes like Window, UserControl, and ListBoxItem get only one view (last writer wins, I think)

ItemsControl and its derrivitives (StatusBar, TreeView, MenuBase, etc.) can hold multiples.

As can Selector derrived like ListBox, ComboBox & TabControl.