tabcontrol prism

Topics: Prism v4 - WPF 4
May 6, 2011 at 1:01 PM

I have a TabControl (with 2 TabItems) and 2 Prism modules.

Every module has the views displayed in different regions of my shell window, including one region which belongs to the respective TabItem(one tabitem is for one view of the first module, and one is for one view of the second module)

I am trying to activate/deactivate all the module views based on the selected tab item.

Example: selecting the first TabItem will display on the Shell only the views from the first module, therefore hiding the views of the second module.

How can I solve this without breaking the rules of MVVM?

May 6, 2011 at 3:22 PM


Based on my understanding on your scenario, one possibility to achieve your requirement would be to subscribe to the TabControl region's ActiveViews CollectionChanged event and publish an event in the EventAggregator (depending on the view selected). You should have the components in your modules subscribe to that event, to add or remove your view depending on the payload specified.

Another possibility would be to use Navigatino instead of the Event Aggregator; for example, you could navigate to your first module's views in case its tab is selected, and then navigate to the second one's views in the other case.

You might find the following chapters useful to learn more about the concepts described:

I hope you find this helpful.

Guido Leandro Maliandi

May 9, 2011 at 8:32 AM



Thank you for your answer. It works good.

Now I am adding tabs using 3 buttons on my UI. How can I set the active tab item based on the active view?



May 9, 2011 at 10:56 AM

Have a look at IActiveAware which can be attached to a view or view model

  • IActiveAware.IsActive tells you the active view in a region
  • IActiveAware.IsActiveChanged tells you when the active status changes