From bb7276d568e2d51127b2134013d63f0d410226f5 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Thu, 9 Jan 2020 10:46:13 +0100 Subject: [PATCH] =?UTF-8?q?Extend=20the=20fix=20for=20Recycling=20the=20fo?= =?UTF-8?q?cused=20element=20to=20non=20virtualized=20l=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit …ayouts * Ensure that we set the m_processingItesmSourceChange flag for non-virtualizing layouts as well as virtualizing ones. Ported from https://github.com/microsoft/microsoft-ui-xaml/commit/cc335ac3915ed37ac7ee95237b789622287d2f5a --- .../Repeater/ItemsRepeater.cs | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/Avalonia.Controls/Repeater/ItemsRepeater.cs b/src/Avalonia.Controls/Repeater/ItemsRepeater.cs index 685d3e44f2..cbac1d6c1b 100644 --- a/src/Avalonia.Controls/Repeater/ItemsRepeater.cs +++ b/src/Avalonia.Controls/Repeater/ItemsRepeater.cs @@ -562,34 +562,34 @@ namespace Avalonia.Controls if (Layout != null) { - if (Layout is VirtualizingLayout virtualLayout) - { - var args = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset); + var args = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset); + try + { _processingItemsSourceChange = args; - try + if (Layout is VirtualizingLayout virtualLayout) { virtualLayout.OnItemsChanged(GetLayoutContext(), newValue, args); } - finally + else if (Layout is NonVirtualizingLayout nonVirtualLayout) { - _processingItemsSourceChange = null; - } - } - else if (Layout is NonVirtualizingLayout nonVirtualLayout) - { - // Walk through all the elements and make sure they are cleared for - // non-virtualizing layouts. - foreach (var element in Children) - { - if (GetVirtualizationInfo(element).IsRealized) + // Walk through all the elements and make sure they are cleared for + // non-virtualizing layouts. + foreach (var element in Children) { - ClearElementImpl(element); + if (GetVirtualizationInfo(element).IsRealized) + { + ClearElementImpl(element); + } } - } - Children.Clear(); + Children.Clear(); + } + } + finally + { + _processingItemsSourceChange = null; } InvalidateMeasure();