Getting new RegionManager from dynamically loaded module

Topics: Prism v4 - Silverlight 4
Feb 20, 2011 at 6:36 PM

I started learning Prsim V4 using the Prism V4 Navigation integration with Silverlight navigation project.  My plan was to create a new moduel based on the inventory module as it demonstrates lots of great concepts.

The problem I am having is I'm trying to use the region manager request navigate function from a view model in a dynamically loaded module and it fails right away.

_regionManager.RequestNavigate(RegionNames.MainContentRegion, Constants.AdministrationHomeView, PostNavigationCallback);

 void PostNavigationCallback(NavigationResult navigationResult)
            if (navigationResult.Result == true)
                MessageBox.Show("Navigation Successful");
                MessageBox.Show("Navigation Failed");

In the post navigation call back I noticed that the NavigationResult objects context property does not have a reference to a navigation service. 
It looks like I am not getting a reference to the region manager from the shell application.

In the ctor of my view model I am importing the region manager. It does get set to a valid object however it is not the region manager from the shell.

public UserViewModel(
      IRegionManager regionManager

 _regionManager = regionManager;


My view model is implementing the following interfaces: 

If there is any additional information that I can provide please let me know.
Feb 21, 2011 at 7:09 PM


I try to reproduce your scenario using the Exercise 3 Hands-On-Lab solution, located in the Navigation folder of the Prism Training Kit

In ModuleA, in the ModuleANavigationItemView on the Button_Click event I do this:

var uri = new Uri(ViewNames.ModuleAView, UriKind.Relative);
regionManager.RequestNavigate(RegionNames.MainRegion, uri, PostCallBack);


and in the callback I have this code:

if (e.Result == true)
        MessageBox.Show("This MessageBox is working, go to target view!");
        MessageBox.Show("Something is not working ok");



In order to take another approach, since nothing in your code seems to be wrong, you could retrieve the instance of the RegionManager using the ServiceLocator in the constructor of your view model, like this:

private readonly IRegionManager regionManager;

public UserViewModel()
     regionManager = ServiceLocator.Current.GetInstance<IRegionManager>();

If you continue experiencing this issue, could you provide us with a repro sample in order to reproduce you specific scenario?

Please let me know if this information helps you.


Miguel Bronzovic

Feb 22, 2011 at 3:01 PM

This works, thank you for the response.