This project has moved and is read-only. For the latest updates, please go here.


Quickest Start

The quickest way to get started is using one of the existing samples in the sample directory


Less Quick start

If you would like to add the AppCan changes yourself it is possible, the second way is to start from a prism app like Hello World and add AppCan Manually.


Start with the basic Hello World prism application. 


Add references to the two main libraries:



 Can also add the external log4net logging library (optional)


Derive the application class from the AppCanApp class:

public partial class App : AppCanApp


Update the App.xaml file so that it references the AppCanApp class:

<z:AppCanApp x:Class="HelloWorld.App"




Change the shell class to derive from the interface IViewContainer:

public partial class Shell : Window, IViewContainer


 Change the Bootstrapper class to take a reference to the app class and should look like this:

using AppCan.Core.Contexts;
using AppCan.wpf.Application;
using AppCan.wpf.Views;
//using log4net;
//using log4net.Config;
using Microsoft.Practices.Prism.Logging;

class Bootstrapper : UnityBootstrapper
        Context _context;
        Window _window;
        App _app;

        public Bootstrapper(App app)
            _app = app;
            //Configure log4net if desired
            //XmlConfigurator.Configure(new System.IO.FileInfo("Log4net.xml"));



        protected override DependencyObject CreateShell()

            //load configuration if desired
            _app.ContextManager.GetNewOrExistingContextDef("HelloWorld.Shell").Container.RegisterType<IViewContainer, Shell>(new ContainerControlledLifetimeManager());


            Context ct =_app.ContextManager.GetNewOrExistingContextDef("HelloWorld.Shell").GetNewContext();
            _context = ct;

            _window = (Window)ct.Container.Resolve<IViewContainer>();

            return _window;


        protected override void InitializeShell()


            App.Current.MainWindow = (Window)this.Shell;


        protected override void InitializeModules()


        protected override void ConfigureModuleCatalog()

            ModuleCatalog moduleCatalog = (ModuleCatalog)this.ModuleCatalog;

        /* If log4net is desired
        protected virtual ILoggerFacade CreateLogger()
            return new Log4NetLogger();
        } */

Derive your Shell class from IViewContainer:
public partial class Shell : Window, IViewContainer
Example Initialize Method for the Hello World module:
 //Get the container
            IUnityContainer container=ServiceLocator.Current.GetInstance<IUnityContainer>();
            //Get the context manager
            IContextManager cm = container.Resolve<IContextManager>();

            //Get the context definition
            IContextDef cd=cm.GetNewOrExistingContextDef("HelloWorld.Shell");

            //Register the view to the context definition 
            cd.Container.RegisterType<IView, HelloWorldView>();

            //Register the view model to the context definition
            cd.Container.RegisterType<IViewModel, HellowWorldViewModel>();

            //Get the context region manager from the context definition 
            IContextRegionManager crm=cd.Container.Resolve<IContextRegionManager>();
            //- we will pre-register that the IView that we registered we want to go to a particular region
            //When the context definition is created the regions will be created into the context
Derive the Modules view from IView and if you have a view model from IViewModel:
public partial class HelloWorldView : UserControl, IView

Last edited Mar 17, 2013 at 3:15 AM by davesspacebar, version 4


No comments yet.