Getting View From Conductor?

Topics: Framework Services
May 12, 2011 at 3:36 PM

I have a class that inherits Conductor<IScreen> and i niticed the base class inherits IViewAware but how do i get the view?

I tried var view = GetView(this) as ShellView; but that didn't work. 

May 12, 2011 at 4:10 PM

var defaultView = GetView();

The parameter is a "context" object that is used when there are multiple views over the same VM, such as in the HelloScreens sample. In that sample you could do this:

var masterView = GetView("Master");

var detailView = GetView("Detail");

May 13, 2011 at 12:06 AM

ah ok, so is Master the name of the View with the string "View" removed?

May 13, 2011 at 12:11 AM

Read the section here on View resolution:

May 14, 2011 at 8:54 AM

it turns out my problem was that i as trying to access a property on my view via an event aggregate triggered by my initialization code before the view had been set. So it confused me a bit when it was returning null. I had to move my initialisation code into the Activated event of the ShellViewModel.