Click here to Skip to main content
15,896,606 members
Articles / Desktop Programming / WPF

Composite WPF Display-on-Demand

Rate me:
Please Sign up or sign in to vote.
4.53/5 (10 votes)
30 Aug 2009CPOL6 min read 46.7K   1.3K   24  
Composite WPF Display-on-Demand.
using System.Windows.Input;
using LoadOnDemandDemo.ViewModel.Commands;
using Microsoft.Practices.Composite.Modularity;
using Microsoft.Practices.Composite.Regions;

namespace LoadOnDemandDemo
{
    public class ShellViewModel
    {
        #region Constructor

        public ShellViewModel(IModuleEnumerator moduleEnumerator, IModuleLoader moduleLoader, IRegionManager regionManager)
        {
            this.Initialize(moduleEnumerator, moduleLoader, regionManager);
        }

        #endregion

        #region Command Properties

        /// <summary>
        ///  Loads Module A.
        /// </summary>
        public ICommand LoadModuleA { get; set; }

        /// <summary>
        /// Loads Module B.
        /// </summary>
        public ICommand LoadModuleB { get; set; }

        /// <summary>
        ///  Unloads Module A.
        /// </summary>
        public ICommand UnloadModuleA { get; set; }

        /// <summary>
        /// Unloads Module B.
        /// </summary>
        public ICommand UnloadModuleB { get; set; }

        #endregion

        #region Module Properties

        /// <summary>
        /// The Prism module loader.
        /// </summary>
        public IModuleLoader ModuleLoader { get; set; }

        /// <summary>
        /// The Prism module enumerator.
        /// </summary>
        public IModuleEnumerator ModuleEnumerator { get; set; }

        /// <summary>
        /// The Prism region manager.
        /// </summary>
        public IRegionManager RegionManager { get; set; }

        #endregion

        #region Private Methods

        private void Initialize(IModuleEnumerator moduleEnumerator, IModuleLoader moduleLoader, IRegionManager regionManager)
        {
            // Initialize command properties
            this.LoadModuleA = new LoadModuleACommand(this);
            this.LoadModuleB = new LoadModuleBCommand(this);
            this.UnloadModuleA = new UnloadModuleACommand(this);
            this.UnloadModuleB = new UnloadModuleBCommand(this);

            // Initialize module properties
            this.ModuleEnumerator = moduleEnumerator;
            this.ModuleLoader = moduleLoader;
            this.RegionManager = regionManager;
        }

        #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)


Written By
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.

Comments and Discussions