From f353998ec44ae59e8f55652626c0fde95faa5ced Mon Sep 17 00:00:00 2001 From: Tako <53405089+Takoooooo@users.noreply.github.com> Date: Wed, 3 Nov 2021 16:26:00 +0200 Subject: [PATCH] Merge pull request #6847 from YohDeadfall/realized-elements-cleanup-on-removal ElementManager follows the behavior of ViewManager --- src/Avalonia.Layout/ElementManager.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Avalonia.Layout/ElementManager.cs b/src/Avalonia.Layout/ElementManager.cs index c2f829d020..681d23a61f 100644 --- a/src/Avalonia.Layout/ElementManager.cs +++ b/src/Avalonia.Layout/ElementManager.cs @@ -314,12 +314,11 @@ namespace Avalonia.Layout } break; + // Remove clear all realized elements just to align the begavior + // with ViewManager which resets realized item indices to defaults. + // Freeing only removed items causes wrong indices to be stored + // in virtualized info of items under some circumstances. case NotifyCollectionChangedAction.Remove: - { - OnItemsRemoved(args.OldStartingIndex, args.OldItems.Count); - } - break; - case NotifyCollectionChangedAction.Reset: ClearRealizedRange(); break;