From cce605af493864b9e996cef1441fc70ccd546c50 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Mon, 9 Sep 2019 23:51:30 +0200 Subject: [PATCH] Remove unused/bad code. Removed the code that was causing the TreeView problems described in #2944. This code was never actually called except in `TreeView` because a plain `ItemsControl` can't be used with virtualization (it uses untyped `ItemContainerGenerator` so items can't be recycled) and every other derived class derives from SelectingItemsControl which overrides this method and doesn't call the base implementation. In addition there were no unit tests covering this code. Fixes #2944 --- src/Avalonia.Controls/ItemsControl.cs | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/Avalonia.Controls/ItemsControl.cs b/src/Avalonia.Controls/ItemsControl.cs index 902e55bde6..0fe7291835 100644 --- a/src/Avalonia.Controls/ItemsControl.cs +++ b/src/Avalonia.Controls/ItemsControl.cs @@ -302,19 +302,6 @@ namespace Avalonia.Controls /// The details of the containers. protected virtual void OnContainersRecycled(ItemContainerEventArgs e) { - var toRemove = new List(); - - foreach (var container in e.Containers) - { - // If the item is its own container, then it will be removed from the logical tree - // when it is removed from the Items collection. - if (container?.ContainerControl != container?.Item) - { - toRemove.Add(container.ContainerControl); - } - } - - LogicalChildren.RemoveAll(toRemove); } ///