Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Event trigger for Shift + Left Click

I have a button in WPF.

When pressed, it activates the ViewModel Command : myBtnClick.

 <Button Command="{Binding myBtnClick}" />

It works fine.

I want to run another command when press Shift + Left Click

Is there a way to do this with Event Trigger?

(I want to keep the principles of MVVM)

like image 291
Hodaya Shalom Avatar asked Jun 09 '13 07:06

Hodaya Shalom


1 Answers

Yes, there is a way. You just need to define InputBindings for your Button:

<Button Command="{Binding myBtnClick}">
   <Button.InputBindings>
       <MouseBinding Gesture="Shift+LeftClick" Command="{Binding MyCommand}"/>
   </Button.InputBindings>
</Button>
like image 70
dkozl Avatar answered Oct 28 '22 01:10

dkozl