This is the first part of an article series on the basics of using Caliburn micro for the MVVM framework in WPF. In this article we will see the benefits of using the MVVM framework and how it can ease your life when working with the MVVM design, especially with WPF. For the series I've chosen Caliburn Micro because this is a lightweight, powerful, easy to use and highly recommended framework with a very good technical documentation. Second we'll talk about the SimpleInjector for IOC (Inversion of control) because this is reported to be the fastest and easiest to use IOC container framework. The IOC container is required with Caliburn micro in the bootstrapper (Entry point) to register all the view model types and other types so that they can be resolved at run times. The IOC keeps our application fully decoupled and this is what MVVM is for. You'll see the true MVVM taste here with fully decoupled views and view models in upcoming posts.
So let's get started with the first step writing the Bootstrapper for the WPF application.
Application Bootstrapper
The bootstrapper is required to register and configure all the runtime and startup components. This will be your entry point of your WPF application. And rather than directly adding the reference to your startup window you'll be registering the bootstrapper in App.XAML.
Writing the bootstrapper.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Caliburn.Micro;
using DataGridSample;
using SimpleInjector;
namespace CaliburnMicroMvvmWpfDemo
{
internal class AppBootstrapper : Bootstrapper<MainWindowView>
{
/// <summary>
/// The global container.
/// </summary>
public static readonly Container ContainerInstance = newContainer();
protected override void Configure()
{
ContainerInstance.Register<IWindowManager, WindowManager>();
ContainerInstance.RegisterSingle<IEventAggregator,EventAggregator>();
ContainerInstance.Verify();
}
protected override IEnumerable<object> GetAllInstances(Type service)
{
return ContainerInstance.GetAllInstances(service);
}
protected override object GetInstance(System.Type service, stringkey)
{
return ContainerInstance.GetInstance(service);
}
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment
It is the same account you read, post and publish with — and you will come straight back to this page.

naresh kumarPosted Dec 17, 2013, 1:29 AM
What benefits does caliburn.micro provides comparing to PRISM and others