diff --git a/src/Avalonia.Controls/Presenters/ItemVirtualizerSimple.cs b/src/Avalonia.Controls/Presenters/ItemVirtualizerSimple.cs index 26b7ccf65f..fc7e36a2a1 100644 --- a/src/Avalonia.Controls/Presenters/ItemVirtualizerSimple.cs +++ b/src/Avalonia.Controls/Presenters/ItemVirtualizerSimple.cs @@ -258,7 +258,8 @@ namespace Avalonia.Controls.Presenters else { // Items have been removed and now the range FirstIndex..NextIndex goes out of - // the item bounds. Try to scroll up and then remove any excess containers. + // the item bounds. Remove any excess containers, try to scroll up and then recycle + // the containers to make sure they point to the correct item. var newFirstIndex = Math.Max(0, FirstIndex - (NextIndex - ItemCount)); var delta = newFirstIndex - FirstIndex; var newNextIndex = NextIndex + delta;