Get a mop and wipe it up!

Caliburn.Micro for Newbies Who Want to Write Clean WP7 Apps - Part 1: How to Configure a New Project With Folders

, posted: 27-Sep-2010 22:10

Caliburn.Micro is an MVVM framework aimed at XAML development (WPF4, SL4 and WP7). I'm particularly interested in it for the benefits it brings to WP7 (Win Phone 7) development:
  • minimal code-behind
  • minimal databinding
  • clean separation between views and view-models (making unit testing easier)
  • simplified navigation between views
(There are many more benefits, but they are more esoteric than my brain can assimilate for now.)

Much of the simplification is achieved by "convention over configuration".  

This series of posts is my journey to understanding Caliburn.Micro for a real Win Phone 7 project. I am not a Caliburn.Micro ninja -- quite the opposite. I take my hat off to Rob Eisenberg for the framework he and his colleagues are creating. But, despite reading his documentation, and source code, I am a slow learner when it comes to putting into practical use. Thus, comments and corrections are encouraged!

So many introductory articles are "Hello World" apps that are TOO trivial. I want a VS2010 solution layout that I can use as a standard starting point for new apps, that encourages me to be a tidy coder. 

  1. You have heard about Caliburn.Micro. (If not, read the Introductory Page)

  2. You have obtained the source code. (Otherwise, I'll wait while you sort that out too. You need a certain level of determination to make this work!)

  3. You have downloaded the RTM developer tools for WP7.

How to start a new Caliburn.Micro WP7 project in Visual Studio?

  1. File-NewProject WindowsPhone7 app.

  2. Add as an Existing Project your Caliburn.Micro WP7 source code project.

  3. To your WP7 project add a Project Reference to the Caliburn.Micro project.

  4. To your WP7 project add Model, Views and ViewModels folders.

  5. Delete the default startup page, MainPage.xaml, as it's in the wrong place.

  6. In the Views folder, create a new WP7 page as your startup screen and call it, say, ShellView.xaml.

  7. In the ViewModels folder, create a new class and call it, say, ShellViewModel.cs. Inherit from a suitable Caliburn.Micro class, eg Screen.

  8. Open the WMAppManifest.xml file in the Properties folder. Change the DefaultTask NavigationPage from MainPage.xaml to Views/ShellView.xaml. 

  9. Build the app and check that it runs the default page.

  10. Add a Model folder to your project.

Now you have a tidy structure for your application, with separate folders for model, view and viewmodel files. 

Important conventions to note so far:
  • a view can be located from a viewmodel via convention: the name of the view (ignoring the file extension) is the name of the viewmodel, but with all instances of the word "Model" removed. Eg, "ViewModels/ShellViewModel.cs" corresponds to the view, "Views/ShellView.xaml".

Coming up next (when I have time)...

Part 2. Navigating between views


More information

Other related posts:
How to get your Windows Azure hosted WordPress contact form working
NuPeek - a local NuGet and Symbol Server for .NET
Bitwise testing in C#

Comment by Lavon, on 28-Nov-2013 19:22

Wow that was strange. I just wrote an incredibly long comment but
after I clicked submit my comment didn't appear. Grrrr...
well I'm not writing all that over again. Regardless, just wanted to say wonderful blog!

Add a comment

Please note: comments that are inappropriate or promotional in nature will be deleted. E-mail addresses are not displayed, but you must enter a valid e-mail address to confirm your comments.

Are you a registered Geekzone user? Login to have the fields below automatically filled in for you and to enable links in comments. If you have (or qualify to have) a Geekzone Blog then your comment will be automatically confirmed and placed in the moderation queue for the blog owner's approval.

Your name:

Your e-mail:

Your webpage:

dmw's profile

David White
New Zealand

Goon fan, .NET developer, contrarian seeker of truth