Click here to Skip to main content
15,886,258 members
Articles / Desktop Programming / WPF

Magellan: An MVC-powered Navigation Framework for WPF

Rate me:
Please Sign up or sign in to vote.
4.92/5 (70 votes)
7 Sep 2010CPOL15 min read 113.2K   1.3K   104  
An introduction to Magellan, an Open Source navigation framework for WPF.
using System.Windows;
using Magellan;
using Magellan.Framework;
using MyMagellanApp.Features.Home;
using MyMagellanApp.Features.Tax;
using MyMagellanApp.Features.Tax.Model;

namespace MyMagellanApp
{
    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    public partial class App : Application
    {
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            // Configure Magellan - first by setting up controllers
            var controllerFactory = new AsyncControllerFactory();
            controllerFactory.Register("Home", () => new HomeController());
            controllerFactory.Register("Tax", () => new TaxController(TaxSelectorFactory.CreateSelector()));

            // Next by configuring our routing rules
            var routes = new ControllerRouteCatalog(controllerFactory);
            routes.MapRoute("{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = "" });

            // The NavigatorFactory is responsible for producing Navigators. This allows you to have multiple 
            // navigators with the same configuration (for example, tabbed browsing)
            var factory = new NavigatorFactory("tax", routes);
            var mainWindow = new MainWindow(factory);
            mainWindow.MainNavigator.Navigate<HomeController>(x => x.Index());
            mainWindow.Show();
        }
    }
}

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
Octopus Deploy
Australia Australia
My name is Paul Stovell. I live in Brisbane and develop an automated release management product, Octopus Deploy. Prior to working on Octopus I worked for an investment bank in London, and for Readify. I also work on a few open source projects. I am a Microsoft MVP for Client Application Development.

Comments and Discussions