MVVM messaging or events or which other option from the list?
I have a menu in MainViewModel, now when I select a specific menu item, I would like to update the data of the already loaded view.
i.e. although there is an instance of this viewModel in the MainViewModel, when I try to call a method through this instance and change the data property, it doesn't show the changes in the view. While the same changes happen when I call this method via relay command using a button on this viewModel.
Now, how do I need to call the relay command of this viewModel from the MainViewModel, I think this will fix the problem, but how do I do it? what's the easiest way. Do I need to use messaging?
source to share
I tried the MVVM Light Messenger class, its quite simple and elegant (keeps ViewModels loosely coupled) !! and most importantly it works
code: Send: Messenger.Default.Send (stringParameter, "key_anything"); Register: Messenger.Default.Register <string> (this, "key_anything", invokeFunction); private void invokeFunction (string stringParamter) { // code goes here! }
source to share