I'm using this way to catch events from XAML:
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseWheel">
<ei:CallMethodAction MethodName="ChangeValue" TargetObject="{Binding DataContext}" />
</i:EventTrigger>
</i:Interaction.Triggers>
This way works well, I can fire my ChangeValue function in my code.
But I would like to know the mouse wheel orientation (up or down) on my ChangeValue function.
Is there a way to do that?
You can use MVVM Light's EventToCommand, which also has a PassEventArgsToCommand property. Then, instead of a method, define a command that receives the event args as a parameter. Your XAML should look something like this:
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseWheel">
<cmd:EventToCommand Command="{Binding ChangeValueCommand}"
PassEventArgsToCommand="True" />
</i:EventTrigger>
</i:Interaction.Triggers>
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