C# WPF Framework: How to Build Caliburn.Micro Quickly

1. What is Caliburn?

Caliburn is an open source framework of MVVM class proposed by Rob Eisenberg on January 26, 2009 (Rob’s mix10 talk “build your own MVVM framework”). It is a set of libraries used to assist in the development of WPF, Silverlight, WP7 and win RT applications.

Caliburn.Micro Officially released by Rob Eisenberg on June 7, 2010.

Caliburn.Micro Is a small and powerful framework designed to build applications on all XAML platforms. With strong support for MVVM and other proven UI patterns, Caliburn.Micro Will enable you to build solutions quickly without sacrificing code quality and testability

2. Project creation:

Step 1: create a project and install it for the current project using nuget package management tool Caliburn.Micro

Step 2: Project Creation:

newly build StartView.xaml

Delete the MainWindow.xaml

Modification App.xaml Delete startupuri=“ MainWindow.xmal “。

<Window x:Class="WpfApp8.StartView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfApp8"
        mc:Ignorable="d"
        Title="StartView" Height="450" Width="800">
    <Grid Background="Gray">
        <Button x:Name="testBtn" Content="testBtn" HorizontalAlignment="Center"  VerticalAlignment="Center" Width="100" Height=" 50" Background="LightCyan"/>


    </Grid>


</Window>


newly build StartViewModel.cs

using Caliburn.Micro;
using System.Windows;


namespace WpfApp8
{
    class StartViewModel : Screen


    {
      
        public StartViewModel()
        {
           
        }


        public void testBtn()
        {
            MessageBox.Show("hello world!");
        }




    }
}


Create a new class that inherits bootstrapperbase. Here I name it mybootstrapper
class

using Caliburn.Micro;
using System.Windows;


namespace WpfApp8
{
    class MyBootstrapper : BootstrapperBase
    {


        public MyBootstrapper()
        {
            Initialize();//Initializing the framework
        }




        protected override void OnStartup(object sender, StartupEventArgs e)
        {
            DisplayRootViewFor<StartViewModel>();//show the main
        }
    }




}


Running results:
0

Read More: