Activate View only from RegionManager.RequestNavigate

Topics: Prism v4 - Silverlight 4
Oct 13, 2010 at 12:39 PM

I have two regions: Main and Details. during Module initialization I register views for Main and Details regions.

I need to Activate and show view in Details region onle after call of RegionManager.RequestNavigate.

Is it possible?

Oct 13, 2010 at 4:13 PM
Edited Oct 13, 2010 at 4:15 PM


Based on my understanding, you have a RegionA, where two regions (Main and Detail) are added. So when you navigate to RegionA, the views registered on both aforementioned regions are displayed. However, your scenario requires to display only the views in the Detail region.

First of all, I would recommend you to design a layout to avoid needing a programmatic control for achieving this if possible. This way, you could navigate to the region that contains only the views that you need to display.

Regarding to the your current scenario, you could use the callback in the RequestNavigation method for achieving this scenario. So your code might be similar to the following:

this.regionManager.RequestNavigate(RegionNames.RegionA, yourViewUri, nr =>
    var yourView = this.regionManager.Regions[RegionNames.RegionA].GetView("YourViewName");


Hope this helps.

Fernando Antivero

Oct 13, 2010 at 4:19 PM

I have to regions MainRegion and DetailRegion.

In Module.Initialize I Register one view (MainView) for module MainRegion and one for DetailRegion (DetailView). I need MainView visible when application starts (it works) and DetailView visible only when I use:

this.regionManager.RequestNavigate(RegionNames.DetailRegion, detailViewUri, nr => {} );

But DetailView is visible at the begining.

Oct 13, 2010 at 7:46 PM
Edited Oct 13, 2010 at 8:00 PM


If your scenario requires to do not display DetailView before you navigate this, you have to use just in time view creation. It consists on do not add/register DetailView in DetailRegion, since it will be created or located automatically when you call the RequestNavigate method using just in time view creation. This technique requires to add the view in the container, so the DetailView view must be decorated using the Export attribute: [Export("DetailView")].
For more information about this you could take a look at the following documentation section in the Prism4.chm:

  • View-Switching Navigation Quickstart (new), see the introduction section and the Implementation Details section

You could note that in the Navigation Quickstart that the views are not registered. So for more information you could check the Navigation Quickstart.

Hope this helps.

Fernando Antivero

Oct 14, 2010 at 10:23 AM
Edited Oct 14, 2010 at 11:06 AM

View-Switching Navigation Quickstart uses MEF for mapping View types to Uri. Am I right?

I use Unity and IUnityContainer.RegisterType(typeof(MyView),"MyView") for this task. But RequestNavigate doesn't see my view. Do i miss something?

Update. It works only when I register my view using:

container.RegisterType<object, MyView>("MyView")

If I use  


it doesn't work.

And second question: Why RequestNavigate navigates to System.Object when it can't find View? I think setting Error property of NavigationContext is better idea.


Oct 15, 2010 at 9:17 PM


Thanks for your feedback. I will copy this as a work-item so the product will be notified. Additionally other users using Unity can vote this.

You are right, the View-Switching Navigation Quickstart is using MEF. What do you mean with it navigates to System.Object? I tried to use a non existent URI in the Navigation Quickstart and navigation fails, keeping the UI in the current view.

Thanks again for your feedback.

Fernando Antivero


Oct 15, 2010 at 9:19 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.