Deactivate ViewModel in ContentControl

Topics: UI Architecture
Oct 18, 2011 at 4:57 PM

If I have a ContentControl that is hooked up against a property of type "MyChildViewModel" in my "FooViewModel", how do I deactivate a instance of MyChildViewModel?

I tried to let a conductor be responsible of the FooViewModel instance and called conductor.Deactivate(viewModelInstance, true), but still no luck in getting OnDeactivate to trigger.

What's the correct way of getting OnDeactivate to be called in a ViewModel that is used in conjunction with a ContentControl?

//Daniel

Oct 19, 2011 at 7:46 PM

Example exists here: https://github.com/danielwertheim/InputBindingCommand-Lab

To get OnDeactivate to be called when an instance of the NestedViewModel (that is opened in SimpleViewModel) I need to explicitly add a Deactivate method and call it in SimpleViewModel. I have tried to use a Conductor in SimpleViewModel and create/deactivate NestedViewModel items via that. No luck.

//Daniel