This project is read-only.

Handeling Commands in MVVM

Jul 19, 2009 at 3:26 PM

I have a general question about where to put the commands.

I have a MenuBar with a ViewModel that represent him, A ContextMenu with a ViewModel.  and some other bottons in another view.

There is some commands that are common for all the ViewModels.  What is the best practice to deal with this situation?

1. Every ViewModel have an instance of the command and in the Execute call for a common logic.

2. There is a common entity (I don't have a name for it) that holds all the instances of the commands, the commands are binded to the view through the ViewModel,

in the command Execute we use the Messanger to send a message for the one how know what to do.


I have a lot of duplicate commands in the ViewModels, and I want to get rid of it.

Thanks for you comments.

Josh I will appreciate if you could ask your fellows Diciples this question.

Ran Trifon 


Aug 4, 2009 at 12:07 PM

face similar problem,

Should use the messenger to communicate between VM for command handling or let prop observer monitor on VM 'sown param and state ?

looking forward to suggestion