I have a project structure as follows:
Modules --- ModuleA ---ViewA ---ViewModelA ---Module --- ModuleB ---ViewB ---ViewModelB ---Module MyApplication ---Shell.xaml ---Bootstrapper MyApplication.Infrastructure --- ---
Now, in the module Module.Module:
[ModuleExport(typeof(Module), InitializationMode = InitializationMode.WhenAvailable)] [PartCreationPolicy(CreationPolicy.NonShared)] public class Module : IModule { IRegionManager _regionManager; [ImportingConstructor] public Module(IRegionManager regionManager) { _regionManager = regionManager; } public void Initialize() { _regionManager.RegisterViewWithRegion(RegionNames.ContentRegion, typeof(ViewA)); } }
Now, in the module Module.Module:
[ModuleExport(typeof(Module), InitializationMode = InitializationMode.WhenAvailable)] [PartCreationPolicy(CreationPolicy.NonShared)] public class Module : IModule { IRegionManager _regionManager; [ImportingConstructor] public Module(IRegionManager regionManager) { _regionManager = regionManager; } public void Initialize() { _regionManager.RegisterViewWithRegion(RegionNames.ContentRegion, typeof(ViewB)); } }
In Shell.xaml:
<DockPanel LastChildFill="True"> <Menu DockPanel.Dock="Top"> <MenuItem Header="Show View A" /> <MenuItem Header="Show View B" /> </Menu> <ContentControl prism:RegionManager.RegionName="{x:Static inf:RegionNames.ContentRegion}"/> </DockPanel>
In bootstrapper.cs
protected override void ConfigureAggregateCatalog() { base.ConfigureAggregateCatalog(); AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(BootStrapper).Assembly)); AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(RegionNames).Assembly)); AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(ModuleA.Module).Assembly)); AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(ModuleB.Module).Assembly)); }
When I launch the application, I get an error message indicating that no export or multiple export was found for ContentRegion. I can understand that I am registering both my submissions in the same region, so I get this error.
But I donβt know how to register my views for navigation purposes, so when I click on MenuItem Show View A , ViewA should appear in the content area. Similarly for ViewB.
source share