Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

A Prism 4 Application Checklist

, 5 Apr 2011 CPOL
The article provides a step-by-step explanation of how to set up a Prism application.
Prism4Demo.zip
Prism4Demo
Prism4Demo.Common
BaseClasses
bin
Events
obj
Debug
TempPE
Prism4Demo.Common.csproj.user
Properties
Prism4Demo.Library
FsTools
FsTaskButton.dll
Prism
Microsoft.Practices.Prism.dll
Microsoft.Practices.Prism.UnityExtensions.dll
Microsoft.Practices.ServiceLocation.dll
Microsoft.Practices.Unity.dll
Ribbon
RibbonControlsLibrary.dll
Prism4Demo.ModuleA
bin
Commands
obj
Debug
TempPE
Views
Prism4Demo.ModuleA.csproj.user
Properties
Settings.settings
Services
ViewModels
Views
Images
LargeIcon.png
module_a.png
SmallIcon.png
Prism4Demo.ModuleB
bin
Commands
obj
Debug
TempPE
Views
Prism4Demo.ModuleB.csproj.user
Properties
Settings.settings
Services
ViewModels
Views
Images
LargeIcon.png
module_b.png
SmallIcon.png
Prism4Demo
bin
obj
x86
Debug
TempPE
Views
Prism4Demo.csproj.user
Properties
Settings.settings
Services
Utility
ViewModels
Views
Images
LargeIcon.png
new.png
open.png
print.png
ribbon.png
save.png
SmallIcon.png
using System.Windows;
using Microsoft.Practices.Prism.Modularity;
using Microsoft.Practices.Prism.Regions;
using Microsoft.Practices.Prism.UnityExtensions;
using Microsoft.Practices.ServiceLocation;
using Microsoft.Windows.Controls.Ribbon;
using Prism4Demo.Shell.Views;
using PrismRibbonDemo;

namespace Prism4Demo.Shell
{
    public class Bootstrapper : UnityBootstrapper
    {
        #region Method Overrides

        /// <summary>
        /// Populates the Module Catalog.
        /// </summary>
        /// <returns>A new Module Catalog.</returns>
        /// <remarks>
        /// This method uses the Module Discovery method of populating the Module Catalog. It requires
        /// a post-build event in each module to place the module assembly in the module catalog
        /// directory.
        /// </remarks>
        protected override IModuleCatalog CreateModuleCatalog()
        {
            var moduleCatalog = new DirectoryModuleCatalog();
            moduleCatalog.ModulePath = @".\Modules";
            return moduleCatalog;
        }

        /// <summary>
        /// Configures the default region adapter mappings to use in the application, in order 
        /// to adapt UI controls defined in XAML to use a region and register it automatically.
        /// </summary>
        /// <returns>The RegionAdapterMappings instance containing all the mappings.</returns>
        protected override RegionAdapterMappings ConfigureRegionAdapterMappings()
        {
            // Call base method
            var mappings = base.ConfigureRegionAdapterMappings();
            if (mappings == null) return null;

            // Add custom mappings
            var ribbonRegionAdapter = ServiceLocator.Current.GetInstance<RibbonRegionAdapter>();
            mappings.RegisterMapping(typeof(Ribbon), ribbonRegionAdapter);

            // Set return value
            return mappings;
        }

        /// <summary>
        /// Instantiates the Shell window.
        /// </summary>
        /// <returns>A new ShellWindow window.</returns>
        protected override DependencyObject CreateShell()
        {
            /* This method sets the UnityBootstrapper.Shell property to the ShellWindow
             * we declared elsewhere in this project. Note that the UnityBootstrapper base 
             * class will attach an instance of the RegionManager to the new Shell window. */

            return new ShellWindow();
        }

        /// <summary>
        /// Displays the Shell window to the user.
        /// </summary>
        protected override void InitializeShell()
        {
            base.InitializeShell();

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

        #endregion
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

David Veeneman
Software Developer (Senior) Foresight Systems
United States United States
David Veeneman is a financial planner and software developer. He is the author of "The Fortune in Your Future" (McGraw-Hill 1998). His company, Foresight Systems, develops planning and financial software.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.141220.1 | Last Updated 5 Apr 2011
Article Copyright 2011 by David Veeneman
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid