How to get dynamic value from View to ViewModel?

I am running into a scenario where I need to do something in view mode according to the current selection in the view, but according to MVVM, the view model should not be aware of the existence of the view, then how can I get the dynamic selection in the view?

+2


a source to share


1 answer


From Josh Smith's article on MVVM

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



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

+3


a source







All Articles