MVVM and Prism – The App, BootStrapper, Shell and Modules

Prism helps create a modular application using something called the Bootstrapper.  This can initiate the Shell (a UserControl that contains Regions where you can place your Modules) and also initiates the ModuleCatalog which manages you modules – opening, closing, positioning, etc.

In the App.xaml.cs change the Application_Startup to read:

<div id="_mcePaste">private void Application_Startup(object sender, StartupEventArgs e)</div>
<div id="_mcePaste">{</div>
<div id="_mcePaste">Bootstrapper b = new Bootstrapper();</div>
<div id="_mcePaste">b.Run();</div>
<div id="_mcePaste">}</div>
private void Application_Startup(object sender, StartupEventArgs e)
Bootstrapper b = new Bootstrapper();

In the Bootstapper you can initiate the RootVisual as the Shell and create a ModuleCatalog and add any modules.

namespace MVVM_Example
public class Bootstrapper : UnityBootstrapper
protected override DependencyObject CreateShell()
Shell shell = Container.Resolve();
Application.Current.RootVisual = shell;
return shell;

protected override Microsoft.Practices.Composite.Modularity.IModuleCatalog GetModuleCatalog()
ModuleCatalog catalog = new ModuleCatalog();
return catalog;

Each module is a separate project that can a number of Views with their ViewModels.

The module needs to be registered with a region.

namespace ModuleA
public class ModuleA : IModule
IRegionManager _regionManager;
IUnityContainer _container;

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

#region IModule Members

public void Initialize()
_regionManager.RegisterViewWithRegion("MainRegion", typeof(Views.ModuleAView));


  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: