Caliburn.Micro – UI Patterns For Solving Real-World Problems

Caliburn.Micro is somewhat interesting. Billed as “A small, yet powerful implementation of Caliburn designed for WPF, Silverlight and WP7. The framework implements a variety of UI patterns for solving real-world problems. Patterns that are enabled include MVC, MVP, Presentation Model (MVVM), and Application Controller.”, and hence somewhat of a replacement for Prism. Of particular interest:

  • One of the benefits of Caliburn is simplification – specifically around auto-binding of views (V) to view models (VM). Ties between V and VM are based on naming convention e.g. MainViewModel and MainView. Binding of properties is along the x:Name lines.
  • One of the downsides of Prism was the IModule, which often got polluted. Caliburn doesn’t require the IModule.
  • Visual components (XAML) have to be registered with caliburn’s AssemblySource – via the bootstrapper

<Application x:Class="AlgoVisualizer.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:MEF="clr-namespace:Caliburn.Micro.Contrib.MEF;assembly=Caliburn.Micro.Contrib">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary>
                    <MEF:MefCaliburnBootstrapper x:Key="bootstrapper"/>
                </ResourceDictionary>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
</Application>

    public class MefCaliburnBootstrapper : Bootstrapper<IShell>
    {
        protected override void Configure()
        {
    ...
   }

  • Most people are aware of the ObserverableCollections UI thread issues, Caliburn resolves this with BindableCollection.
  • IWindowManager is quite nice with its ShowWindow method.
  • ActionMessages offer bind UI triggers (e.g. ‘Click’ event) to methods on the VM

Finally, the project is active, and full source code is available.

Advertisement

~ by mdavey on January 14, 2011.

One Response to “Caliburn.Micro – UI Patterns For Solving Real-World Problems”

  1. Not sure what you mean by registering UI components. The only components you have to register are your view models with whatever container you’re using.

    Lots of other interesting stuff in CM though…
    Take a look at the IResult/Co-Routines stuff for async co-ordination. Probably best solution we have until c#5 async.

    The UI composition and databinding conventions for the contentcontrol are really powerful.
    They allows you to treat your application as a set of navigable and embeddable viewmodels, with all XAML being resolved via the viewmodel binder.

    It takes a little longer to get you’re head around compared tosomething like MVVM Light but once you start to get it, it completely changes the way you structure your app.

    It’s nice to have the same framework available for wpf/sl/wp7 as well…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.

Join 273 other followers