From 2337da31b1367b57c61ff70b1489f7817d31be6b Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Fri, 7 Aug 2020 15:17:18 +0200 Subject: [PATCH] Add null check for scroller. --- src/Avalonia.Controls/Repeater/ViewportManager.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Avalonia.Controls/Repeater/ViewportManager.cs b/src/Avalonia.Controls/Repeater/ViewportManager.cs index 796ae8616d..bdb0fa3270 100644 --- a/src/Avalonia.Controls/Repeater/ViewportManager.cs +++ b/src/Avalonia.Controls/Repeater/ViewportManager.cs @@ -350,11 +350,14 @@ namespace Avalonia.Controls } // Make sure that only the target child can be the anchor during the bring into view operation. - foreach (var child in _owner.Children) + if (_scroller is object) { - if (child != targetChild) + foreach (var child in _owner.Children) { - _scroller.UnregisterAnchorCandidate(child); + if (child != targetChild) + { + _scroller.UnregisterAnchorCandidate(child); + } } }