deactivate a view

Topics: Prism v2 - WPF 3.5
Jun 5, 2009 at 3:46 PM
Edited Jun 5, 2009 at 4:02 PM


In my application I am loading the different Module On-Demand by clicking on a button which appear when the user identify himself in the AuthenticateModule.

         private void MemberModuleButton_Click(object sender, RoutedEventArgs e)

        private void ContratModuleButton_Click(object sender, RoutedEventArgs e)


All my module are stored in the ModuleCatalog in my Bootstrapper and I created some region in the Shell :

<ItemsControl  cal:RegionManager.RegionName="{x:Static infrastructure:RegionNames.ContratRegion}" />


Now, when the user is logged and clicked to the "ContractModuleButton", I registered the View with the region :



Everything work fine but when the user logged off, I want to deactivate the view in order to return to the basic shell.

I tried to use this method without success and I had a error message : "Deactivation is not possible in this type of region. "

var view = container.Resolve<ContratsView>();         



Thanks for your help !

Best regards







Jun 5, 2009 at 9:38 PM

Hi Vlado,


This exception is most likely being thrown because you are using an ItemsControl as your region. This kind of control is mapped to an AllActiveRegion, which can hold multiple views and all of them are active at the same time. Therefore, there is no way to activate a view in an AllActiveRegion. There are two options to avoid the exception:

1.       If you want to stop showing that view and still use the AllActiveRegion you should remove the view from the region or make it not visible.

2.       If you consider a ContentControl would suit your scenario, you will be able to deactivate views, since only one view can be active in a region adapted in a ContentControl (SingleActiveRegion).


Please let me know if this helps.


Damian Schenkelman

Jun 9, 2009 at 3:44 PM

Another time, thanks for your help.

It's work well now with just a simple method :

        public static void UnloadModule() //deactivate View
            foreach (var region in regionManager.Regions)
                if (region.Views.Count() > 0 && region.Name.CompareTo("AuthenticateRegion")!=0)

and exactly the opposite in order to reactivate the view when another user is logged.