Main Application Menu

Topics: Prism v4 - WPF 4
Nov 26, 2011 at 8:37 PM

Hi All,

I'm currently trying to make a decision about how to create a main menu in a prism app.

Initially I was going to have a menu builder module and interface to expose the register (etc ...) menuitemviewmodels.  This is fine for modules but then I started thinking about the File menu with it's "Exit" command which should really be handled in the Shell exe rather than some random module designed to help manage the menu.

Not sure if I've explained this situation very well but I'd appreciate any input on how to go about solving this one.




Nov 29, 2011 at 1:26 PM
Edited Nov 29, 2011 at 1:32 PM


In order to close an application the closing event should be handled in the Shell, hence your module should have a way to notify when this event occurs. For example you could have your Shell subscribe to an event through the event aggregator, so that it performs the appropriate operation to close your application when that event is published.

Take into account that depending the ShutdownMode you implement, the way your application react to the call may be different.

On the other hand, I believe you might find the following threads useful where similar issues are addressed.

I hope you find this useful

Agustin Adami

Dec 5, 2011 at 4:53 PM

@aadami, how would you recommend handling the case where we need to verify shutdowns can continue?  For example, I have several "dirty" viewmodels (my editable object in the view model  has changed), and I have a button on a view in my ToolbarRegion that publishes an event to the Shell to shutdown. I've read a little about using CompositeCommands to offer the Save option on all viewmodels that need to save data, but it also said how this might not be the best approach.  What is the best approach for handling this issue?

Dec 5, 2011 at 7:32 PM


You might find the following blog post by Brian Noyes useful, where a possible approach to handle the aforementioned scenario is proposed:

I hope you find this helpful,

Damian Cherubini