Question

i'm practicing in Prism V4.1 with Silverlight 5 (MefBootstrapper). Unfortunately I can't find implementation of situation like this:

  1. I have 2 Regions in my Shell.xaml.
  2. My modules(xap files described in modulescatalog.xaml)(Module1 and Module2) are injected in this regions;
  3. One of my views in module(Module1 for example) has it's own regions.

And I'd like to use power of prism framework to inject another modules to this Module1 View. In fact this module should be a little prism application with it's own modules which should have possibilities to pass params to Module2 and others.

Is there any way to implement this?

I mean: can view inside the Module1 create its own Region, so dependent module can inject view into this Region?

Was it helpful?

Solution

Yes it can, why not? Just register the views with this region after a dependent module is loaded. For instance, you can do it in the IModule.Initialize method of the dependent module:

public void Initialize()
{
    regionManager.RegisterViewWithRegion("Module1RegionName", () => serviceLocator.GetInstance<DependentModuleView>());
}

Then you can navigate to this view or activate it whenever you want as soon as it is registered.

regionManager.RequestNavigate("Module1RegionName", new Uri("DependentModuleView", UriKind.Relative));

//or resolve the view and activate it
var view = serviceLocator.GetInstance<DependentModuleView>();
var region = regionManager.Regions["Module1RegionName"];
region.Activate(view);

As for the communication between modules you have a few options. Read Communicating Between Loosely Coupled Components for more information.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top