From 1cd80712e9de504a738db6b7d41b2b5701fd3647 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Fri, 24 Feb 2023 14:16:53 +0100 Subject: [PATCH] Bump collection change event priority. Post collection changes to UI thread with higher priority than `Layout` so that all collection changes are processed before the next layout pass. `VirtualizingStackPanel` maintains its own mapping of Items -> Containers, and updates that mapping when a `CollectionChanged` event is received, but it also expects that mapping to be up-to-date when a layout is performed. Fixes #10399 --- src/Avalonia.Controls/Utils/CollectionChangedEventManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Avalonia.Controls/Utils/CollectionChangedEventManager.cs b/src/Avalonia.Controls/Utils/CollectionChangedEventManager.cs index 9d13daa453..675e9e13e5 100644 --- a/src/Avalonia.Controls/Utils/CollectionChangedEventManager.cs +++ b/src/Avalonia.Controls/Utils/CollectionChangedEventManager.cs @@ -141,7 +141,7 @@ namespace Avalonia.Controls.Utils else { var eCapture = e; - Dispatcher.UIThread.Post(() => Notify(_collection, eCapture, l)); + Dispatcher.UIThread.Post(() => Notify(_collection, eCapture, l), DispatcherPriority.Send); } } }