Open jumhyn-browser opened 6 months ago
The new ScrollPresenter and ScrollView controls indeed do not support the IScrollSnapPointsInfo interface.
That is a feature that we are considering for a future release.
In the meantime, it requires some work on the app side to have effective snap points. You need to manually add them to the inner ScrollPresenter. Look for ScrollSnapPoint
, RepeatedScrollSnapPoint
(if the StackPanel has equally sized items) classes.
ScrollPresenter has these properties that you can use:
Windows.Foundation.Collections.IVector<ScrollSnapPointBase> HorizontalSnapPoints { get; };
Windows.Foundation.Collections.IVector<ScrollSnapPointBase> VerticalSnapPoints { get; };
(And also
Windows.Foundation.Collections.IVector<ZoomSnapPointBase> ZoomSnapPoints { get; };
which you probably do not care about.)
To access the inner ScrollPresenter, use ScrollView's
Microsoft.UI.Xaml.Controls.Primitives.ScrollPresenter ScrollPresenter{ get; };
Example:
ScrollSnapPoint snapPoint1 = new ScrollSnapPoint(snapPointValue: 100, alignment: ScrollSnapPointsAlignment.Near);
scrollPresenter.VerticalSnapPoints.Add(snapPoint1);
Hope this helps for now.
@RBrid thanks for the suggested workaround! I'll give the manual approach a try
Describe the bug
Creating a
ScrollView
which wraps e.g. aStackPanel
does not appear to respect snap points, and doesn't have the same APIs available. Weirdly, theScrollTo
method does accept a parameter which purports to use snap point knowledge, but interaction-based scrolling doesn't appear to use them.Is this on the roadmap for future support? Or is there an API I'm missing?
Steps to reproduce the bug
StackPanel
with content in aScrollViewer
(and set appropriate snap point mode)ScrollViewer
to aScrollView
(remove snap point mode setting since the API doesn't exist)Expected behavior
No response
Screenshots
No response
NuGet package version
None
Windows version
No response
Additional context
No response