Thoughts on Progressively Retrofitting Caliburn.Micro

Jul 30, 2010 at 12:33 AM

First off, thank you for the MIX demo. It is clearly generated a lot of excitement. In particular, in making MVVM a lot more accessible to the unwashed folks such as myself. In particular, you have avoided talking using Pattern language, and that has certainly helped. 

The question for today is "Is Caliburn.Micro suited for progressively retrofitting an existing Silverlight Navigation Application?" I'm keen to adopt Caliburn in baby-steps.

I've drawn up a learn-by-doing roadmap. Comments are appreciated!

1) Migrate to ViewModel and Views, but not using the framework to bind the two together, but doing so manually using ViewModelBinder

2) Turning the async queries inside out and using co-routines. I'm in land, at the moment, and it sounds like I'll have to add a separate C# DLL project to support this.

3) Try to figure out how Screen ties in with the bundled Silverlight Navigation Framework, or how it can be migrated out cleanly.



Jul 30, 2010 at 2:59 AM
Edited Jul 30, 2010 at 3:05 AM

Those sound like reasonable steps to me. Here's some thoughts:

1. Yes. The ViewModelBinder can be used completely independently of anything else. So, this is a good first step.

2. Unfortunately, I don't think VB has iterators yet. So, that makes the co-routine technique a C# only thing for the moment.

3. I'm working on some pieces to improve the situation with WP7. I haven't checked in my work yet. When I do, you should take a look at it. There are some pieces related to navigation and screens. You may be able to adapt it. Perhaps I will make some of it available in the SL version. I don't know yet. Right now I'm trying to get WP7 working well...then I'll look at migrating it back to the SL4 version.

Here's a snippet from what I'm working on:


    public class PhoneApplicationFrameAdapter : INavigationService
        readonly PhoneApplicationFrame frame;

        public PhoneApplicationFrameAdapter(PhoneApplicationFrame frame)
            this.frame = frame;

            frame.Navigating += OnNavigating;
            frame.Navigated += OnNavigated;

        void OnNavigating(object s, NavigatingCancelEventArgs e)
            var fe = frame.Content as FrameworkElement;
            if (fe == null)

            var deactivator = fe.DataContext as IDeactivate;
            if (deactivator != null)

        void OnNavigated(object s, NavigationEventArgs e)

            var viewModel = ViewModelLocator.LocateForViewType(e.Content.GetType());
            ViewModelBinder.Bind(viewModel, (DependencyObject)e.Content, null);

            //TODO: IHaveSubject check?

            var activator = viewModel as IActivate;
            if(activator != null)


You can wire to the navigation events and then use a ViewModelLocator to find the VM and the ViewModelBinder to put it together with the view. There's no ViewModelLocator in Caliburn yet, but it does the opposite of the ViewLocator. By adding these event handlers, you transform the navigation service into a little more of a ScreenConductor. Anyways, I hope that gives you some ideas. You'll probably see this in the framework very soon.