0
votes

Using Prism, I've got a INFRASTRUCTURE project, where I've got a view with two regions:

  • ContentRegion
  • SidebarRegion

enter image description here

There's no problem in SidebarRegion, because this is a especif view of this project. But ContentRegion is different, I've got another modules like ModuleA, ModuleB, and these one contain the view which must be show in ContentRegion.

I mean, the INFRASTRUCTURE PROJECT contains the generic view. And the others module contains a view which must be showed in ContentRegion

I'm using Prism and UNITY. Can you orient me about how can I do this? I guess I need to register the views but I'm lost.

1

1 Answers

1
votes

You should be able to pass the Region Manager and Unity container to the modules through the constructor. Then you can use those to register your views in the Initialize method, like so:

public class ModuleA : IModule
{
    private readonly IUnityContainer _container;
    private readonly IRegionManager _regionManager;

    public ModuleA(IUnityContainer container, IRegionManager regionManager)
    {
        _container = container;
        _regionManager = regionManager;
    }

    public void Initialize()
    {
        _regionManager.RegisterViewWithRegion("ContentRegion",
            () => _container.Resolve<NameOfYourView>());
    }
}

And, of course, you have to make sure the modules are loaded properly, but I'm assuming that is done already.