Breaking the MVVM pattern while using Caliburn Micro

Jan 13, 2011 at 7:33 PM

Hi, 

I'm using Caliburn Micro & Silverlight 4. 

I have a Canvas on a View that I'm drawing 2d objects on. 

The objects I draw on the canvas are dependent on some objects that I have instantiated in my ShellViewModel. 

So I modified the constructor on my CanvasViewModel to accept the objects. 

How do I either: 

1. Access the objects in the CanvasViewModel from the CanvasView to draw them?

2. Skip the View - ViewModel for this area, put the drawing code in the View code behind and call the View from the ShellViewModel? 

Let me know if you need any other info from me to help. 

Thanks!

Jan 13, 2011 at 8:32 PM

I found this article: 

http://sonyarouje.wordpress.com/2010/09/09/an-experiment-in-caliburn-micro/

Wherein the author is creating a Canvas object in the ViewModel, then (not sure if Caliburn is doing it or not) this is wired up to the Canvas on the View. 

I have duplicated this portion, creating a canvas object in my CanvasViewModel, with the same name as the canvas object in my view. 

I'm getting a convention exception though, so I'm guessing I need to add one? 

Jan 13, 2011 at 8:34 PM

Does Caliburn have to have an element convention for every type of item it might need to bind? 

All I'm really trying to do is have it bind the canvas object on my ViewModel to the canvas object on my View. 

That doesn't make me think I'd need a convention, or is that incorrect? 

Jan 13, 2011 at 9:45 PM

I've tracked it down to the bootstrapper, where Caliburn has found the Canvas object on my ViewModel, but cannot find it on the View. 

var property = viewModelType.GetPropertyCaseInsensitive(parts[0]);

I've checked that 'viewModelType' is pointing to the correct view, but 'property' in this case is always returning null.
I made sure that my Canvas object in the View has the same name as the Canvas object in my ViewModel, so what am I missing?