This project is read-only.

Before you start developing Windows Phone 7 applications you will need to download and install  Windows Phone Developer Tools if you haven't done this already. This StackOverflow question also contains useful list of Windows Phone 7 resources.

Getting Started

To use Columbus, reference Columbus.dll in your project.

First, you need to create Columbus navigation application and hook it up to phone application. To do that in App.cs file add following code:


            var navApp = NavigationAppication.CreateSingleFrameApplication(
                n => n.NavigateTo<HomeController>(c => c.HomePage()));
            PhoneApplicationService.Current.Activated += navApp.Activated;
            RootFrame.Navigated += navApp.StatusChanged;


Implement LocateController and LocateView functions to resolve your views and controllers by name.

<Skip this part if you are not using IoC container>

If you are using IoC container you can use code like:


            var navApp = container.Resolve<NavigationAppication>();
            PhoneApplicationService.Current.Activated += navApp.Activated;
            RootFrame.Navigated += navApp.StatusChanged;


Container must be configured so it can resolve navigation application, for example configuration for Autofac may look like:


    public class ApplicationModule : Module
        protected override void  Load(ContainerBuilder builder)
            // Registering all views and controllers in current assembly
                .Where(t => typeof(PhoneApplicationPage).IsAssignableFrom(t))
                .Named<FrameworkElement>(t => t.Name);
                .Where(t => typeof(Controller).IsAssignableFrom(t))
                .Named<Controller>(t => t.Name);

            // Navigation
            builder.Register<Func<string, Controller>>(c => x => c.ResolveNamed<Controller>(x));
            builder.Register<Func<string, FrameworkElement>>(c => x => c.ResolveNamed<FrameworkElement>(x));
                .WithParameter("defaultAction", new Action<INavigator>(n => n.NavigateTo<HomeController>(c => c.HomePage())));
                .WithParameter("frameName", Navigator.DefaultNavigationFrameName);


</Skip this part if you are not using IoC container>

Next thing you need is to add navigation frame to display your application content. In your main page (by default it is MainPage.xaml if you've created your project from Visual Studio template, I usually rename it to Shell) remove all xaml content (you can leave root Grid), add namespace Controls phone application page: 


and navigation frame:

<Controls:Frame x:Name="Content" />

You'll also need to create home page for your application (page displayed first when application is loaded), let's name it HomePage.xaml.

Technically MainPage is the page that is displayed first but in Columbus powered application MainPage (or Shell if you rename it like I do) is just a shell to host navigation frame that will be displaying your application content. Apart from frame, shell can contain any other UI elements and can play a role of Master Page for your application. Shell can even have a View Model (you can use Columbus.ShellViewModelBase class to inherit shell view model from) that can survive tombstone, have access to navigator and support other things that Columbus view models support. Shell can also host multiple independent navigation frames to create rich user experience.

Last thing you need to add is controller and default action. You may have noticed that we have already added code that uses controller and default action when we created navigation application:

n => n.NavigateTo<HomeController>(c => c.HomePage())

Controller must inherit Columbus.Controller, action must return Columbus.ActionResult:


    public class HomeController : Controller
        public ActionResult HomePage()
            // Specifying view name is not required if view name is the same as controller action name
            return Page();


Now you can run your application and see that HomePage is loaded.

If you create and pass view model as part page action result then when your page is loaded view model will be automatically assigned to its DataContext. If passed view model inherits Columbus.ViewModel, you'll be able to also use navigation (so from your view model or command of your view model you can just say Navigator.NavigateTo<SomeController>(c => c.SomeAction()) to navigate wherever you want to) and other Columbus view model features (surviving tombstone, easy and testable choosers, persisting constructor parameters).

For more samples, download Columbus source code and have a look into 'Sample Applications' folder.

Last edited Dec 10, 2010 at 12:35 AM by ArtemGovorov, version 3


No comments yet.