Align (scrolling) TabControl with MD spec #3981
Draft
+301
−2
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.
Fixes #3976
This is a work in progress attempting to align the
TabControl(scrolling) style with the MD spec.The PR contains the following changes:
TabControlHeaderScrollBehaviorin order to react the tab/scroll events.StackPanel(currently namedBringIntoViewHijackingStackPanelto signal intent) in order to hijack and re-raise theRequestBringIntoViewevent.ScrollViewerand the containedTabItems. It "hijacks" theFrameworkElement.RequestBringIntoViewEventby marking it as handled, and subsequently issue a newFrameworkElement.BringIntoView(Rect)call with aRectmatching the original event, but offset left/right based on scroll direction.ScrollViewer.ScrollToHorizontalOffset()- thanks @Keboo for that idea!TabAssist.TabScrollDurationAP to allow consumers to control the animation duration.TimeSpan.Zeroeffectively disables the animation.Styleto allow easy override at the call site.TabAssist.TabScrollOffsetAP to allow consumers to modify the offset (i.e. "padding" from above).Styleto allow easy override at the call site.I have done some preliminary testing and I think it works pretty well. However I don't have a mouse with a mouse-wheel-tilt feature, so that part lacks testing (I could imagine that may cause some issues). I have tried to avoid conflicts with it by setting a private variable (
_desiredScrollStart) when the scrolling is initiated from a tab change. I hope that is enough, but only testing will show.Things to look at before PR is ready:
Debug.WriteLinestatements.BringIntoViewHijackingStackPanelis really the name we want for this panel.FlowDirection=RightToLeftworks as expected.Preview of the feature