Frage

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)

War es hilfreich?

Lösung

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>
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top