Closed SetTrend closed 2 months ago
@SetTrend Please attach your sample app where you are able to reproduce the issue.
@singhashish-wpf:
Please find the MCVE here: SetTrend/mousegestureissue
I added steps to reproduce to the example repository's ReadMe.md
file.
Did anyone have the time to investigate on this issue?
Did anyone have the time to investigate on this issue?
@SetTrend
1) You're calling base.Matches
first, but your override initializes with MouseAction.None
, on which the base (MouseGesture
) call will always return false.
Therefore we have two solutions:
1) Initialize with MouseAction.WheelClick
instead of MouseAction.None
, then your code works out of the box.
2) Stop using the base check and check yourself for Modifiers flags (using Keyboard.Modifiers
as source of truth, which is what MouseGesture
does) + that the event is MouseWheelEventArgs
.
Excellent answer! Thanks a lot for enlightening me!
Welcome, only took 3 years to figure this one out, right 😄
Problem description:
Having created a custom command like this:
And having written a
MouseWheelGesture
like described here: https://stackoverflow.com/questions/2271342/mousebinding-the-mousewheel-to-zoom-in-wpf-and-mvvm#answer-7527482The
MouseWheelGesture.Matches()
method is not getting called when the mouse wheel is rotated while the CTRL key is getting pressed.Actual behavior:
The
MouseWheelGesture.Matches()
method is getting called for the CTRL key is being pressed, but not for the mouse wheel being rotated.Expected behavior:
The
MouseWheelGesture.Matches()
method should be getting called when the mouse wheel being rotated with aMouseWheelEventArgs
event argument.dotnet --info
)Laufzeitumgebung: OS Name: Windows OS Version: 10.0.19043 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\5.0.400\
Host (useful for support): Version: 5.0.9 Commit: 208e377a53
.NET SDKs installed: 3.1.412 [C:\Program Files\dotnet\sdk] 5.0.303 [C:\Program Files\dotnet\sdk] 5.0.400 [C:\Program Files\dotnet\sdk]
.NET runtimes installed: Microsoft.AspNetCore.All 2.1.29 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.29 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.18 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.29 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.18 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.18 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
To install additional .NET runtimes or SDKs: https://aka.ms/dotnet-download
21H1 Build 19043.1165