Creating VM/View in code

Sep 24, 2010 at 12:19 PM

I am using the Telerik Docking control. I am attempting to create a new RadPane in code and set the content to a viewmodel, and am hoping there is an easy way to have CM bind it to the view:

RadPane radPane = new RadPane();
var dbvm = new DashboardViewModel();
radPane.Content = dbvm;

The above does not find the DashboardView and bind it. After reading through the docs and searching the discussions, I do not see a recommended way to do this in code.  

Sep 24, 2010 at 1:28 PM

Caliburn.Micro.View.SetModel(radPane, dbvm) should work. 

Sep 24, 2010 at 2:05 PM

That worked perfectly. Thanks very much for your assistance and all of your contributions to CM.

Jul 25, 2011 at 4:53 PM

Great information. I've been looking for this information for a few days now.