1

I am trying to add support for horizontal scrolling with the touchpad to my WPF application.

I am working on an HP laptop with a working touchpad: Under Windows -> Settings -> Touchpad it says "Your PC has a precision touchpad" and offers extensive options. The multiple finger gestures work, and two-finger swiping to scroll horizontally works on several apps that I tried; in short, the touchpad is perfectly capable of issuing multi-touch events.

Vertical scrolling and zooming already work thanks to some layer converting these touch events to mouse events, and this layer does also convert horizontal touch events to WM_MOUSEHWHEEL events, but WPF ignores those. There exists a feature request to add WM_MOUSEHWHEEL support to WPF here: https://github.com/dotnet/wpf/issues/3201 but it is currently assigned to nobody, and the year is 2023.

I have found this solution here: https://stackoverflow.com/a/47457389/773113 (also here: https://blog.walterlv.com/post/handle-horizontal-scrolling-of-touchpad-en.html) but it gets dirty with AddHook() and WM_MOUSEHWHEEL, so I have the following issues with it:

  • I find it hard to believe that one has to resort to such gimmicks in order to achieve something as simple and commonplace as receiving touchpad input.

  • These gimmicks have a strong windows-only smell to me, whereas in the future I see one of the following happening:

    • Either Microsoft will release a cross-platform version of WPF to go with NetCore, so windows-specific gimmicks will be inapplicable, or
    • I will switch from WPF to Avalonia, in which case, windows-specific gimmicks will, again, be inapplicable.

So, I would rather not use walterlv's solution if I can avoid it.

While looking for an alternative I stumbled upon the concept of "manipulation" in WPF, and I thought that this might do it, but as it turns out, this entire manipulation mechanism of WPF for some reason applies only to touchscreens, not touchpads, even though I can see no practical difference between the two.

So, is there any way to support horizontal scrolling with the touchpad in my WPF application without resorting to WM_MOUSEHWHEEL?

asked Mar 12, 2023 at 7:34
2
  • Wpf is windows only, forever. Maui is cross platform. some software houses like unity. Blazor is perhaps something else to consider. Commented Mar 12, 2023 at 11:48
  • There are plenty of issues in WPF that are resolved with Hooks. So I would suggest to use this option (at least for now). Only thing else I can think of, would be to inject into wpf WinUI2 controls, however that would be even more worse (from clean code prospective) then a simple Win32 hook Commented Mar 13, 2023 at 10:49

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.