From 5d813c901190a678a5ef43698726b734f64f11a8 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Tue, 2 Jul 2019 14:37:53 +0200 Subject: [PATCH] Scaffold IScrollAnchorProvider on ScrollViewer. It doesn't do anything yet, but `ItemsPresenter` requires `ScrollViewer` to implement this interface. --- .../Repeaters/ViewportManager.cs | 2 +- src/Avalonia.Controls/ScrollViewer.cs | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.Controls/Repeaters/ViewportManager.cs b/src/Avalonia.Controls/Repeaters/ViewportManager.cs index 7a34d7f12a..c32ac3855f 100644 --- a/src/Avalonia.Controls/Repeaters/ViewportManager.cs +++ b/src/Avalonia.Controls/Repeaters/ViewportManager.cs @@ -365,7 +365,7 @@ namespace Avalonia.Controls.Repeaters public void ResetScrollers() { _scroller = null; - _effectiveViewportChangedRevoker.Dispose(); + _effectiveViewportChangedRevoker?.Dispose(); _effectiveViewportChangedRevoker = null; _ensuredScroller = false; } diff --git a/src/Avalonia.Controls/ScrollViewer.cs b/src/Avalonia.Controls/ScrollViewer.cs index 264b1fd2ce..c9b5cbb75b 100644 --- a/src/Avalonia.Controls/ScrollViewer.cs +++ b/src/Avalonia.Controls/ScrollViewer.cs @@ -11,7 +11,7 @@ namespace Avalonia.Controls /// /// A control scrolls its content if the content is bigger than the space available. /// - public class ScrollViewer : ContentControl, IScrollable + public class ScrollViewer : ContentControl, IScrollable, IScrollAnchorProvider { /// /// Defines the property. @@ -333,6 +333,9 @@ namespace Avalonia.Controls get { return _viewport.Height; } } + /// + IControl IScrollAnchorProvider.CurrentAnchor => null; // TODO: Implement + /// /// Gets the value of the HorizontalScrollBarVisibility attached property. /// @@ -373,6 +376,16 @@ namespace Avalonia.Controls control.SetValue(VerticalScrollBarVisibilityProperty, value); } + void IScrollAnchorProvider.RegisterAnchorCandidate(IControl element) + { + // TODO: Implement + } + + void IScrollAnchorProvider.UnregisterAnchorCandidate(IControl element) + { + // TODO: Implement + } + internal static Vector CoerceOffset(Size extent, Size viewport, Vector offset) { var maxX = Math.Max(extent.Width - viewport.Width, 0);