You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, MouseWheel events are only sent in response to vertical mouse wheel scrolling; no event is sent for horizontal scrolling despite Windows sending a window message in response to horizontal mouse/touchpad scrolling. This means that horizontal scrolling does nothing in WPF apps, unless the app manually listens for and interprets the horizontal mouse wheel event and responds to it manually.
Reacted by lindexi, Bastian Schmidt, theoractice, Jan Kučera, emoacht, Shaojun Li, Michael Wood and Symbai
privateIntPtrHook(IntPtrhwnd,intmsg,IntPtrwParam,IntPtrlParam,refboolhandled){constintWM_MOUSEHWHEEL=0x020E;switch(msg){caseWM_MOUSEHWHEEL:inttilt=(short)HIWORD(wParam);OnMouseTilt(tilt);return(IntPtr)1;}returnIntPtr.Zero;}privatestaticintHIWORD(IntPtrptr){varval32=ptr.ToInt32();return((val32>>16)&0xFFFF);}privatevoidOnMouseTilt(inttilt){// Your code}
I was going to request the same. WPF doesnt support scrolling horizontally using "mouse" devices only. Not via mouse wheel (including the classic mouse wheel with up/down, but there are also mouse wheels which you can move to left or right), and not via touchpad.
But this feels like it should be implemented into WPF by default. @lindexi The workaround you mention, just like the other hacks, are really annoying to implement. You'd have to do that for every control which has scroll support in every page of your application.
@lindexiIt is unclear to me how using MOUSEWHEEL hook tells us if it scrolls horizontal and not vertical. Imagine a scrollviewer where BOTH scrollbars are shown at the same time and the user uses a touchpad for example. He can scroll up/down but also left/right. So what exactly is sent to the application in both cases, where does it differ and how to other frameworks react on this. (WM_MOUSEHWHEEL is not the same as WM_MOUSEWHEEL)
Adding to existing public events would be a breaking change. So I agree with #3201 that it should add a new public event.
Also it seems that this request has another open issue with some ideas of how to implement: #3201
Maybe its worth it to merge both.
As for the SHIFT + mouse wheel. I just used this workaround (Creating a new class inheriting the ScrollViewer, overridding the OnMouseWheel event. At least this wouldn't cause any public surface changes. I think that we should probably add this separately. One PR adds the SHIFT + scroll support (which can be done already) and a second PR should be made for WM_MOUSEHWHEEL hook (which takes longer as it adds new public events and we must discuss the names etc)
Adding to existing public events would be a breaking change.
How?
Because the existing wheel change event has no indicator if its about horizontal or vertical. Adding such an indicator like a boolean forces developers to check that. Existing code wouldn't check that, so it breaks.
You could add a different property carrying the horizontal value only, for example HorizontalDelta, so that the existing applications are not affected.
The convincing argument in #3201 for this to be separate event is that it comes as a separate event from the Window subsystem.
I am in favor of closing this as duplicate of #3201
Instead of closing you should have merged posts. And nobody said anything to my suggestion about making a separate PR for shift + mouse wheel support.... the "duplicate" doesn't cover this.
@miloush: This still break existing code as you don't know what developers are doing in this event. They could be calling another method regardless of the delta value. And right now it is SAFE that its only for vertical scrolling.
Instead of closing you should have merged posts. And nobody said anything to my suggestion about making a separate PR for shift + mouse wheel support.... the "duplicate" doesn't cover this.
@miloush: This still break existing code as you don't know what developers are doing in this event. They could be calling another method regardless of the delta value. And right now it is SAFE that its only for vertical scrolling.
I am happy to merge the issues, I just don’t know how. If I can figure out how to merge it, I’ll reopen and merge it.
That is not a standard Windows behavior and I would need some convincing to support it out of the box. It doesn't work like that in Notepad/Paint/native controls, Word (it does in VS or Adobe Reader). It's Ctrl+Shift+Scroll for Excel, Ctrl+Scroll in Illustrator/Photoshop etc. Windows Explorer scrolls horizontally using normal scrolling if there is horizontal scrollbar only.
ghost locked as resolved and limited conversation to collaborators on Jun 11, 2023
Activity
lindexi commentedon Jan 12, 2022
Symbai commentedon May 9, 2023
I was going to request the same. WPF doesnt support scrolling horizontally using "mouse" devices only. Not via mouse wheel (including the classic mouse wheel with up/down, but there are also mouse wheels which you can move to left or right), and not via touchpad.
There are some "hacks" to achieve that:
https://blog.walterlv.com/post/handle-horizontal-scrolling-of-touchpad-en.html
https://stackoverflow.com/questions/4158101/how-to-horizontally-scroll-in-wpf-using-mouse-tilt-wheel
https://stackoverflow.com/questions/54549047/shift-mouse-wheel-to-scroll-horizontally (using Shift + a classic mouse wheel works fine in for example Microsoft Edge)
But this feels like it should be implemented into WPF by default. @lindexi The workaround you mention, just like the other hacks, are really annoying to implement. You'd have to do that for every control which has scroll support in every page of your application.
lindexi commentedon May 9, 2023
@Symbai Do you thank adding the new event or adding to existing event is better?
Symbai commentedon May 9, 2023
@lindexi
It is unclear to me how using MOUSEWHEEL hook tells us if it scrolls horizontal and not vertical. Imagine a scrollviewer where BOTH scrollbars are shown at the same time and the user uses a touchpad for example. He can scroll up/down but also left/right. So what exactly is sent to the application in both cases, where does it differ and how to other frameworks react on this.(WM_MOUSEHWHEELis not the same asWM_MOUSEWHEEL)Adding to existing public events would be a breaking change. So I agree with #3201 that it should add a new public event.
Also it seems that this request has another open issue with some ideas of how to implement: #3201
Maybe its worth it to merge both.
As for the SHIFT + mouse wheel. I just used this workaround (Creating a new class inheriting the ScrollViewer, overridding the
OnMouseWheelevent. At least this wouldn't cause any public surface changes. I think that we should probably add this separately. One PR adds the SHIFT + scroll support (which can be done already) and a second PR should be made forWM_MOUSEHWHEELhook (which takes longer as it adds new public events and we must discuss the names etc)miloush commentedon May 9, 2023
How?
Symbai commentedon May 9, 2023
Because the existing wheel change event has no indicator if its about horizontal or vertical. Adding such an indicator like a boolean forces developers to check that. Existing code wouldn't check that, so it breaks.
miloush commentedon May 9, 2023
You could add a different property carrying the horizontal value only, for example
HorizontalDelta, so that the existing applications are not affected.The convincing argument in #3201 for this to be separate event is that it comes as a separate event from the Window subsystem.
I am in favor of closing this as duplicate of #3201
aquinn39 commentedon May 9, 2023
Closing this as a duplicate of #3201.
Symbai commentedon May 9, 2023
Instead of closing you should have merged posts. And nobody said anything to my suggestion about making a separate PR for shift + mouse wheel support.... the "duplicate" doesn't cover this.
@miloush: This still break existing code as you don't know what developers are doing in this event. They could be calling another method regardless of the delta value. And right now it is SAFE that its only for vertical scrolling.
aquinn39 commentedon May 9, 2023
I am happy to merge the issues, I just don’t know how. If I can figure out how to merge it, I’ll reopen and merge it.
miloush commentedon May 9, 2023
That is not a standard Windows behavior and I would need some convincing to support it out of the box. It doesn't work like that in Notepad/Paint/native controls, Word (it does in VS or Adobe Reader). It's Ctrl+Shift+Scroll for Excel, Ctrl+Scroll in Illustrator/Photoshop etc. Windows Explorer scrolls horizontally using normal scrolling if there is horizontal scrollbar only.