Based on my understanding of your scenario, you could load on demand your module in your Shell´s btnLoad click event by doing this modification in your code:
public partial class MainWindow : Window, IPartImportsSatisfiedNotification
private readonly IRegionManager _regionManager;
private readonly IModuleManager _moduleManager;
public MainWindow(IRegionManager regionManager, IModuleManager moduleManager)
this._moduleManager = moduleManager;
private void btnLoad_Click(object sender, RoutedEventArgs e)
This code will load your module class on demand, and since your Initialize method is registering the view
UserControl1 with MainContent region, it will load your view into aforementioned region in your shell.
You should take into account that UserControl1 must be decorated with the
On the other hand, another approach could be to load your module on demand in the btnLoad_Click event and in the
OnImportSatisfied handler, subscribe to ModuleManager´s
LoadModuleCompleted. In this handler you could use the ServiceLocator to retrieve your UserControl1 view instance and add it to
MainContent region like this:
public void OnImportsSatisfied()
this.moduleManager.LoadModuleCompleted += this.ModuleManager_LoadModuleCompleted;
private void ModuleManager_LoadModuleCompleted(object sender, LoadModuleCompletedEventArgs e)
var myView = ServiceLocator.Current.GetInstance<IUserControl1>();
It should be noted that the way UI Composition is performed in Prism is by declaring named regions (for example, in the shell) and adding views from other units of functionality (for example, modules) into that regions. In order to achieve that, the component
adding views to a region must know that region’s name, or else there is no way for that component to indicate where to place that visual component. On the other hand, the shell should have no notion of the views that are being added to a region inside
it from a separate module; that’s one way to decouple visual components from the layout in which they’re being added in Prism.
Please let me know if this information helps you.