Caliburn.Micro Xaml made easy

Add the ShellView

Contents Previous Next

Add the ShellView

For the time being, each ViewModel should have a View with exactly the same name, but the name should end with View instead of ViewModel and it should be stored in the Views folder.

Caliburn.Micro promotes a programming style where you use one window and then show user controls inside this window. This works OK. In this tutorial it will be shown how this works, but it also will be shown how to use dialog windows and mode less windows. Fortunately this is fully supported as well.

Create the ShellView class

Since we already created a class ShellViewModel we also need a WPF Window named ShellView, so create a new WPF Window class in the View folder. You do not need any specific inheritance here.

Add a content control

Though it is not yet, used, at this point add a ContentControl to the ShellView.

<ContentControl x:Name="ActiveItem" Margin="20"/>

You should make sure to use the name ‘‘ActiveItem`` here, because this is a Caliburn.Micro naming convention. This name will be used later to locate where the user controls should be displayed.


The XAML code now looks like this:

<Window x:Class="Caliburn.Micro.Tutorial.Wpf.Views.ShellView"
        Title="ShellView" Height="450" Width="800">
    <ContentControl x:Name="ActiveItem" Margin="20"/>

Delete MainWindow.xaml

The final step is to delete MainWindow.xaml. Alternatively you could have renamed it and moved it to the ViewModels folder. This is a useful strategy if you want to migrate existing projects to a Caliburn.Micro based solution.

Contents Previous Next