Click here to Skip to main content
15,895,784 members
Articles / Desktop Programming / WPF

Navigating the different modules through a TreeView in Prism.

Rate me:
Please Sign up or sign in to vote.
4.38/5 (4 votes)
31 May 2012CPOL10 min read 34.4K   2.2K   20  
Describes using TreeView navigation in the standard PRISM.
using System;
using System.ComponentModel.Composition;

using Microsoft.Practices.Prism.Modularity;
using Microsoft.Practices.Prism.Regions;
using Microsoft.Practices.Prism.MefExtensions.Modularity;
using Microsoft.Practices.ServiceLocation;

using NavModule_One.Views;
using NavInfrastructure;

namespace NavModule_One
{
    [ModuleExport("NavModule_One.ModuleInit", typeof(NavModule_One.ModuleInit))]
    public class ModuleInit : IModule
    {
        private readonly IRegionManager _regionManager;
        public IServiceLocator _serviceLocator;

        [ImportingConstructor]
        public ModuleInit(IRegionManager regionManager, IServiceLocator serviceLocator)
        {
            _regionManager = regionManager;
            _serviceLocator = serviceLocator;
        }

        #region IModule Members

        public void Initialize()
        {
            // Use View Discovery to automatically display the MasterView when the TopLeft region is displayed.
            _regionManager.RegisterViewWithRegion(NameRegions.NavigationTreeViewRegion, () => _serviceLocator.GetInstance<NavigationModuleOneView>());
        }

        #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
freelancer
Poland Poland
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions