Prism-MEF: Tabbed Interface Hell

Topics: Prism v4 - WPF 4
Feb 24, 2013 at 8:34 PM
Edited Feb 24, 2013 at 8:42 PM
Hi,
I'm struggling with the following scenario and i don't now if Prism is capable of accomplishing it or not?
I have the following scenario:
ShellWindow: contains
1-NavigationRegion: contains tow tabs CustomerList, OrdersList
2-Main Region: Tabbed Region (TabControl)
3-Details Region : display details of the object in the selected tab in Main Region

When Customer is selected in customerList: event is published of Customer object where subscribers display the following:
MainRegion display a new tab open contains customer object data
DatailsRegion display a group of tabs contains: Orders, Contacts, History, ...each in different tab
questions
1-When many tabs are open in MainRegion, each contain different customer when i click a previous customer tab header the Details region still display the data belong the last customer selected from the customer list.how to make tab content in details region change with clicking different tabs (it change only w/ selecting Customer in CustomerList) - i tried to make ShellWindow publish an event when tab header is selected but i don't know how to transfere
the customer object in the selected tab from xaml to the view model to publish it.
2-Now if i selected an Order in OrderList in NavigationRegion Tabs representing Order Objects are open in MainRegion beside the Customer tabs,i need different user control contain different group of tabs pertaining to Order object to be displayed in DetailsRegion same way like Customer details how to replace user control containing tabs belonging to Customer object with user control containing tabs belonging to Order Object

Plzzz i need somebody to till me if this is possible or not and if possible how?
Feb 26, 2013 at 5:53 PM
Hi,

Based on my understanding of your problem, I think that a possible solution for both cases could be subscribing to the event raised when the active view changes in the MainRegion . This way, when you click on a previous tab or open a new one (from Customers or Orders), since tabbed controls can only have 1 active view at the moment, the ActiveViews.CollectionChanged event will be raised and you will be able to get the necessary information from the ActiveViews collection item to update the Details region accordingly.

In order to subscribe to the ActiveViews.CollectionChanged event, you can use the following code snippet:
this.regionManager.Regions["MainRegion"].ActiveViews.CollectionChanged += ActiveViews_CollectionChangedHandler;
Also, in order to be able to update the Details regions correctly when switching between Customers and Orders, you should wipe out all views from the Details region (which are related to the previous tab) and load the new ones using the approach mentioned above.

I hope you find this useful,

Federico Martinez
http://blogs.southworks.net/fmartinez