I am having some difficulties binding a command (ICommand) to the MouseBinding of a ListView.
I used this piece of XAML code to test the different mouse gestures:
<ListView.InputBindings>
<MouseBinding Command="{Binding OpenSOACommand}" Gesture="LeftClick" />
<MouseBinding Command="{Binding OpenSOACommand}" Gesture="MiddleClick" />
<MouseBinding Command="{Binding OpenSOACommand}" Gesture="LeftDoubleClick" />
</ListView.InputBindings>
The LeftClick and LeftDoubleClick gestures aren’t triggered, yet the MiddleClick mouse binding works perfect (I have tested the mouse bindings one at a time as well…).
Is there a difference in the way the LeftDoubleClick and MiddleClick Gesture is handled? And if there is, how can I bind my ICommand to the LeftDoubleClick gesture?
Thanks!
The default
Clickevent for the ListView is marking the event as handled. Try usingPreviewLeftClickandPreviewLeftDoubleClickinsteadEDIT
Since
MouseBindingsdoes not contain aPreviewLeftClickorPreviewLeftDoubleClick, try using theAttachedCommandBehaviorcode found here which allows you to attach aCommandto just about anyEventFor example,