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
)
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With