tags:

views:

38

answers:

1

I am coming across a scenario where I need to do something in the viewmodel according to the current selection in the view, but according to MVVM, the view model should not know about the existence of view, then how can i get the dynamic selection in the view?

+3  A: 

From Josh Smith's Article on MVVM

Unlike the Presenter in MVP, a ViewModel does not need a reference to a view. The view binds to properties on a ViewModel, which, in turn, exposes data contained in model objects and other state specific to the view.

Hence you can have a property in your ViewModel and bind it to the ListView's SelectedItem.

Veer
this is what i am thinking.
Benny