Fix for 2923: Ignore vertical scroll inside TabControl header. - #2924
Merged
Conversation
There is already a MainScrollViewer in place which handles the scrolling, so there is no need for the additional ScrollViewer; in fact this is what was causing scrolling not to work correctly when hovering the expanders.
Changed to file scoped namespace. Introduced attached property to effectively disable the vertical scroll on a ScrollViewer.
Keboo
approved these changes
Oct 30, 2022
Keboo
approved these changes
Nov 3, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix for #2923
This PR introduces
ScrollViewerAssist.IgnoreVerticalScrollattached property which effectively allows a user to opt-in on disabling vertical scrolling in aScrollViewer. It works by registering for the already handledMouseWheelevent, and then bubbling a copy of that event on its parent element.A ScrollViewer will by default - as far as I know - consume (handled=true) the
MouseWheelevent, even if there is nothing for that particularScrollViewerto scroll in (i.e. all content is displayed and visible in the viewport). The problem in the issue mentioned above was that theTabControluses aScrollViewerinside its header to enable horizontal scrolling (if there is not enough room for the tabs I presume), but thatScrollViewerconsumes the verticalMouseWheelevents as well; effectively disabling scrolling all together when the mouse hovers theScrollViewer.In scenarios like these where you want "horizontal" scrolling only, you can apply the attached property mentioned above. You can argue that you could end up with double-scrolling if the nested
ScrollViewer(and the outerScrollViewer) actually CAN scroll vertically AND you apply this attached property. However I see that as a somewhat unlikely scenario... In those cases you should of course not use the attached property.I applied the attached property on the
ScrollViewerin theMaterialDesignTabControlBasestyle and also added a sample to the demo application to showcase that it still works with scrollable content inside of the tab control.The issue mentions that there is also a problem with the expander, but I believe that was just an issue in the demo application which had a not needed
ScrollVieweradded toExpander.xaml.