I hate wasting time - life’s too short to do everything on your own, that’s why I re-use whatever’s worth re-using. Sometimes licensing costs may be a problem, but usually it’s not that hard to find something for a reasonable price. My latest hunt was for MVVM framework for Silverlight.

For those who don’t know what is MVVM and why should I bother with that if I can make an application in a traditional way - please check the following links out:

http://en.wikipedia.org/wiki/Model_View_ViewModel
http://blogs.elangovanr.com/post/What-is-MVVM-and-Why-MVVM.aspx

In theory, implementing MVVM on your own shouldn’t be a problem, but if you want to:
  • isolate View from ViewModel (using Dependency Injection)
  • make some smart binding (not only on data level, but also on command level)
  • completely avoid code-behind in Views
  • create a modular solution (like an app-hub for plug-inable functionality)
you’ll have to put some real effort into that.
Few months ago I’ve started working with Prism - MVVM framework created by Microsoft. You can find it here: http://compositewpf.codeplex.com/ It has some clear advantages (it works with various IoC containers and serves WPF as well as Silverlight) and it’s quite well documented, but to be honest I found it complex and unpleasant to use. This experience cooled by enthusiasm down a bit, but fortunately there are some other options worth looking at:
They all have few nice pros - including open licensing model and support for WPF, Silverlight and WP7. But… I’m not gonna write about any of them, because I’ve found that the creator of Caliburn has created another framework - Caliburn.Micro (http://caliburnmicro.codeplex.com/) which is very simple to use, very light and is capable of doing 80%-90% of “fully fledged” frameworks like Cinch. I’ve decided to check it on my own and… I’m positively surprised.
 
What’s cool in Caliburn.Micro:
  1. It’s available on NuGet :)
  2. It’s based on “convention over configuration” paradigm! For instance, every view model is automatically bound to its view(s) by name and if you bind properties in your XAML, Caliburn.Micro will look for corresponding properties in your ViewModel. Easy peasy.
  3. It provides some neat helpers - like based classes for ViewModels and INotifyPropertyChanged implementations.
  4. It supports MEF “by design”. Yes, I’m a MEF-addict.
  5. Even if it’s so tiny, it supports WPF, Silverlight and WP7 as well!
  6. It introduces few interesting concepts like: coroutines, conductors and activation. You can read up and make your opinion on those concepts here: http://caliburnmicro.codeplex.com/documentation
  7. It allows you to extend conventions! So, if you’re gonna use external vendor controls (for example: Telerik), you’ll be able to add some additional convention rules, so binding to them will be as easy as binding to default Silverlight controls.
What’s _not_so_cool_ in Caliburn.Micro:
  1. It’s missing some functionality present in “bigger” frameworks - for instance: ViewModel validation support
  2. Convention over configuration works nicely as long as you work with Microsoft controls or other controls inherited from Microsoft controls. In other cases either you’re going to be more messy or you prepare your own convention rules (but that requires some bigger effort) - there’s a package for Telerik controls on NuGet, but it has plenty of flaws (sadly)
  3. If you go too deeply in “convention over configuration” your code may (surprisingly) become less clear and harder to debug
  4. Documentation is very sparse and incomplete
We’re making a small Silverlight application for our client and we’ve decided to take this risk and use Caliburn.Micro in development, so some further feedback may appear in forthcoming weeks.
Share this post