Reputation: 6378
I'm using PRISM and Unity Container.
I've got in my shell a TabControl
with a region called MainRegion
.
Then I have in another project called Common a view. This view contains a ContentRegion
region and two buttons below of it.
Using this common project, I create several Modules which reference the Common project. When I create a new Module, I need to create the view where it should place it in ContentRegion
from the last project.
Please check the image below.
I mean each Module which I create, I need to create a View for the ContentRegion.
I do not know how to implement this situation, can you orient me?
Upvotes: 1
Views: 4201
Reputation: 279
It's a bit hard to tell what you're trying to do based on your question, but I'll give it a shot. It looks like what you want are locally scoped region managers.
So in each Module, you will add the common view to the tab control region. It might look something like this:
public class ModuleA
{
public ModuleA(IRegionManager regionManager)
{
_shellRegionManager = regionManager;
}
public bool Initialize()
{
IRegion tabRegion = _shellRegionManager.Regions["tabRegion"];
//You may actually want to use your container to resolve the common view, but
//I'm creating it here for demonstration sake.
Object commonView = new CommonView();
//This is the important part... setting the 3rd parameter to true gives us
//a new locally scoped region manager, so Prism won't complain about the fact
//that the common view contains regions with names that have already been
//registered in other modules
IRegionManager localRM = tabRegion.Add(new CommonView, "ModuleACommon", true);
IRegion commonContentRegion = localRM.Regions["ContentRegion"];
commonContentRegion.Add(new ModuleAView());
}
IRegionManager _shellRegionManager;
}
Upvotes: 1