Caliburn.Micro and SimpleContainer

If you don’t want to use a fully fledged IoC container, then you can use the simple one Caliburn.Micro contains. It’s needed to support the Windows Phone development, but works with WPF, which is my interest.  It’s a source release, and you can get from Nuget, as Caliburn.Micro.Container.

Of course, Caliburn.Micro has it’s own direct access to any IoC, like this in a ViewModel ctor:-

public ShellViewModel()
windowsmgr = Caliburn.Micro.IoC.Get<IWindowManager>();

But it makes testing difficult and this direct use should be avoided.

What SimpleContainer allows you to do is this:-

public ShellViewModel(IEventAggregator events, IWindowManager wm)
{ = events;
this.windowsmgr = wm;

Where SimpleContainer will inject the EventAggregator and WindowManager automatically, if set up in the Bootstrapper.

I’m attaching two examples, which work with CM 1.4.1, and for VS2012 and Net4.5.
One I wrote myself, and the other was added as a sample within Caliburn.Micro’s discussions, which I’ve updated.

It’s easier for you to read the code in the examples than for me to write any more here.

Have fun! (2.81 mb) (2.81 mb)

AvalonDock v2 and Caliburn Micro (2.16 mb)

A new version of AvalonDock is due to be released early March. See
I thought I would attempt to integrate with Caliburn Micro, which should be easier now, as v2 of AvalonDock is MVVM compatible.

To integrate there are two ways that I know of,

(a.) to create a Custom Attached Property or Behaviour as suggested by Felice Pollano, http//

(b.) to create a Custom Convention along the lines that Valeriu Caraulean has done for Telerik controls,

I thought I’d do both. I’ve used the same test program that Valeriu created.

In the attached Zip, I have included both the associated Caliburn.Micro sources and AvalonDock as at 28th Feb, 88810, which is why the Zip might be a bit big. But I hope it means you can compile and test the solution without fishing for other components.

(a.) Works very well. Simple Activate and Deactivate Message Boxes enable you to track how the Conductor OnActive tracks the usage of the tabs.

(b.) Has a bug I can’t find! The Active ViewModel is Deactivated twice when the application closes down.
In certain circumstances, it can cause the app to crash on shutdown. Solution (a.) does not suffer from this.

I hope you find it useful and interesting. Perhaps you can fix the bug!
I’ll attempt to keep this updated as newer versions of AvalonDock are released

Updated 6th March
I've updated AvalonDock to 89121.
Also updated the Zip with an improved version of how Tab Closing is handled in the Caliburn Convention version.
Still has the closedown problem however.

Updated 8th March
I've changed TestBehaviour to hold a collection of ViewModels instead of Views as in the original.
It's brought out the Style and Template for the Header to the Tab View to better handle the closing.
I've made a small change to Screen.cs to prevent the double Deactivate on shutdown of the app.