From 36d17f509930eced34ed5e4d6707f3fbb7bbc6a7 Mon Sep 17 00:00:00 2001 From: Meloman19 Date: Mon, 2 Oct 2023 01:34:09 +0300 Subject: [PATCH] Finding ancestor IScrollAnchorProvider instead ScrollViewer. (#13079) Co-authored-by: Meloman19 <23280622+Meloman19@users.noreply.github.com> --- src/Avalonia.Controls/VirtualizingStackPanel.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Avalonia.Controls/VirtualizingStackPanel.cs b/src/Avalonia.Controls/VirtualizingStackPanel.cs index d7ff12ffe7d..a255b38bc83 100644 --- a/src/Avalonia.Controls/VirtualizingStackPanel.cs +++ b/src/Avalonia.Controls/VirtualizingStackPanel.cs @@ -67,7 +67,7 @@ public class VirtualizingStackPanel : VirtualizingPanel, IScrollSnapPointsInfo private double _lastEstimatedElementSizeU = 25; private RealizedStackElements? _measureElements; private RealizedStackElements? _realizedElements; - private ScrollViewer? _scrollViewer; + private IScrollAnchorProvider? _scrollAnchorProvider; private Rect _viewport = s_invalidViewport; private Dictionary>? _recyclePool; private Control? _focusedElement; @@ -211,7 +211,7 @@ protected override Size ArrangeOverride(Size finalSize) new Rect(u, 0, sizeU, finalSize.Height) : new Rect(0, u, finalSize.Width, sizeU); e.Arrange(rect); - _scrollViewer?.RegisterAnchorCandidate(e); + _scrollAnchorProvider?.RegisterAnchorCandidate(e); u += orientation == Orientation.Horizontal ? rect.Width : rect.Height; } } @@ -229,13 +229,13 @@ protected override Size ArrangeOverride(Size finalSize) protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e) { base.OnAttachedToVisualTree(e); - _scrollViewer = this.FindAncestorOfType(); + _scrollAnchorProvider = this.FindAncestorOfType(); } protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e) { base.OnDetachedFromVisualTree(e); - _scrollViewer = null; + _scrollAnchorProvider = null; } protected override void OnItemsChanged(IReadOnlyList items, NotifyCollectionChangedEventArgs e) @@ -702,7 +702,7 @@ private void RecycleElement(Control element, int index) Debug.Assert(ItemsControl is not null); Debug.Assert(ItemContainerGenerator is not null); - _scrollViewer?.UnregisterAnchorCandidate(element); + _scrollAnchorProvider?.UnregisterAnchorCandidate(element); var recycleKey = element.GetValue(RecycleKeyProperty);