Is it possible to notify a region owner when a view is added?

Topics: Prism v2 - WPF 3.5
Feb 1, 2010 at 4:01 AM

Hi All

I've been trying to add InputBindings to some commands. Unfortunately it is not working because the commands are defined in views that are 'imported' in a region in the Shell. Because this region (normally) never has focus, the commands are never executed. I've seen several questions on this subject but none of the answers actually solve the problems, which are:

  1. The commands belong to the individual views so there is no way that the shell (or which ever window that holds the region) knows about the command. Thus there is no way that the keybinding ever gets activated
  2. The Prism delegate command doesn't define InputBindings (or a name etc.) so we have to manually bind

I think the work around for problem 2) is to simply define a RoutedCommand (standard WPF one) on the control / view which redirects to the Prism delegate command. This way we should be able to get names and key bindings etc. So that leaves me with problem number 1. Now I'm wondering if it is possible for a view to add commands & keybindings to the shell / window that holds the view. This way it would be possible for the window / shell to 'know' about the commands without actually hard coding them.

Any ideas? Suggestions? Comments?



Aug 2, 2010 at 8:35 AM

I have come across this exact same problem recently. No solution yet, but my thinking was to add something (a service or controller or the like) in my ViewModelBase class, which can communicate with the shell regarding keybindings. Then I would register all of my keybindings (a nightmare idea, I know) on the shell to at least have it trigger, and then route to the correct viewmodel. Now, I am a total noob with the Prism stuff at this stage, so this solution would by any means just be forcing a square into a round hole.

Sep 30, 2010 at 9:53 PM


There is no guidance on this topic in Prism out-of-the-box. So I could take a look at the following forum thread:

I hope this help.

Fernando Antivero