views:

250

answers:

2

Hi girls and guys!

I recently looked into Prism (aka the Composite Application Library for WPF) and really like the way I can structure my apps with it.

However there is one downside that I just couldn't resolve. Is it possible to bind a command (from a ViewModel for instance) to an Event (for example: RightMouseButtonDown) via Prism?

This would be a key requirement to the application I am trying to build and it would be a shame if I couldn't use Prism just because of this lacking feature.

Best regards, crischu

A: 

While it's not part of Prism, you can use the AttachedBehaviours from Marlon Grech.

Cameron MacFarland
+2  A: 

This isn't part of Prism, but you can define input handlers at the window level in WPF with the following code:

<Window.InputBindings>
    <MouseBinding MouseAction="RightClick" Command="RightClickCommand"/>
</Window.InputBindings>

It will then trigger the RightClickCommand defined in its current DataContext (the ViewModel for the window) whenever the RightMouse is clicked within the window and not captured by any other control in the logical tree - the event bubbles up from the control directly under the mouse.

Martin Harris
problem with this is you cant use binding on your Command or CommandParameter
Schneider