views:

76

answers:

1

In my composite WPF application I am injecting some buttons into the shell's toolbar from a module. These buttons are injected using the region manager in the module's IModule Initialize function.

Since I'm using MVVM and Commands, where would an appropriate place be to put the Command handlers (Execute and CanExecute) for the injected buttons? Right inside the IModule class?

+1  A: 

Since this is tagged under MVVM, I assume each "menu button(s)" view you have has a view model. Your view model can contain the handlers for the ICommand (See relay command here). Your view would bind to the ICommands on your view model. I see no reason to hook any events to your IModule. Personally, I never do anything in the IModule::Initialize besides setup dependency injection and initialize my controllers.

Jeremiah Morrill
Since I am using Composite WPF, my view is my shell, and I am injecting the menu buttons from other modules. Therefore I cannot put the commands in the shell's viewmodel.What do you mean by "initialize my controllers"? There are no controllers in MVVM?
emddudley
You should really look at the StockTraderRI and how they use "Controllers" they are not the same concept as controllers in MVC. The controllers in the prism context basically handle all view injection and lower level UI stuff.
Jeremiah Morrill