Problem getting view from RegionManager

Topics: Prism v4 - WPF 4
Sep 21, 2011 at 6:59 PM

I'm working on Login Screen for my application. I took sample of behavior-driven Popup window from StockTrader RI.

Basically, when my Security module loaded - I display my LoginView like so(in module Initialize):

this.RegionManager.RequestNavigate(Constants.SL.Regions.MainPopup, new Uri("/LoginView", UriKind


This works great.. Now in my view model I need to close this view when Login happened on my  "Login" command

I'm trying to do this:

var view = this.RegionManager.Regions[Constants.SL.Regions.MainPopup].GetView("LoginView");


But I get view as NULL from region manager.

1. Is it proper approach for closing view?

2. How to properly get view? I understand in order to GetView I need to create view using Name. But RequestNavigate doesn't support it..

Sep 21, 2011 at 8:03 PM

Ok, I think I figured it out. Does anybody see any issuw with this approach?



view =




v => v.GetType().Equals(






Sep 21, 2011 at 10:41 PM


I´m glad that you found a solution to your problem. In my opinion, there should be any issue with the approach that you proposed. Thanks for sharing it with the rest of the community.

However, if you still wish to retrieve a view from the region through a "name," a possible approach would be to implement your own RegionNavigationContentLoader (based in the RegionNavigationContentLoader from the Prism library) that could add the view to the region using the URI as the name of the view doing something like the following in the LoadContent method:

region.Add(view, navigationContext.Uri.ToString());

Then you can register your custom RegionNavigationContentLoader in the container, without having to modify the Prism library.

However, have in mind that this may not work with some scenarios.


Damian Cherubini

Oct 18, 2011 at 9:47 PM


You might find the following blog post useful, which contains more information about this:

I hope you find this useful.

Agustin Adami

Oct 31, 2011 at 12:52 PM

I had teh same issue. The issue is RequestNavigate does not add the view with a key like RegisterViewWithRegion does. So GetView with key is not going to work. I ended up writing a extension method for IRegionManager that would do that for me.