Question

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)

Was it helpful?

Solution

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>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top