ViewModel Location

Topics: Bootstrappers & IoC, Conventions, Getting Started
Sep 21, 2011 at 2:27 PM
Edited Sep 21, 2011 at 2:58 PM

I have a Windows Phone 7 application that was written using Caliburn Micro v1.0 that I'm trying to update to use v1.2 but I'm running in to a problem that's really bugging me and the views are not being bound to the viewmodels. In my application all of my view models are in the project.viewmodels namespace and the views are in the project namespace, but when I try and run it loads the mainpage.xaml view but it's not bound to any viewmodel. However, if I move the viewmodels in to the project namespace it will work fine.

I have created a simple demo application here: that highlights the issue, I'm guessing that I've got something wrong with my naming conventions but any help would be appreciated!


Sep 21, 2011 at 2:51 PM

We've been making some fixes recently. Can you please try the latest code and see if your issue is still present?

Sep 21, 2011 at 3:14 PM

I've just tried it with changeset 6636e9b93700 and I have the same problem

Sep 21, 2011 at 4:29 PM

The convention is as follows:

Project.ViewModels.SomeViewModel => Project.Views.SomeView


Project.SomeViewModel => Project.SomeView

You will need to override the default behavior by adding your own rule in the boot strapper:


This is a very simple modification to the existing rule to omit the "Views" from the derived namespace. So while this will cover your existing use case:

Project.ViewModels.SomeViewModel => Project.SomeView

It will also resolve the name in the following way should you further nest the namespace for your ViewModels in the future:

Project.ViewModels.SomeNameSpace.SomeViewModel => Project.SomeNameSpace.SomeView


Sep 22, 2011 at 8:36 AM

Thanks for your help guys, I didn't have a great deal of joy with it but restructuring my project to put all of my views within the project.Views namespace solved the problem.