From 3dbfd2303c8dd9ade8d61ae5f80e7cc5a7f6fd4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Pen=CC=83alba?= Date: Tue, 5 Nov 2024 17:11:33 +0100 Subject: [PATCH] Post SelectIndexCentered to the dispatcher Otherwise, the layout for the ListBox is not ready, and calling _listBox.SelectIndex(bestIndex); causes virtualization issues (all the items in the list are realized, causing the UI to underperform) --- src/AvaloniaEdit/CodeCompletion/CompletionList.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/AvaloniaEdit/CodeCompletion/CompletionList.cs b/src/AvaloniaEdit/CodeCompletion/CompletionList.cs index 96d1b72..3a3a566 100644 --- a/src/AvaloniaEdit/CodeCompletion/CompletionList.cs +++ b/src/AvaloniaEdit/CodeCompletion/CompletionList.cs @@ -27,6 +27,7 @@ using Avalonia.Controls.Primitives; using Avalonia.Input; using Avalonia.Interactivity; using Avalonia.Markup.Xaml.Templates; +using Avalonia.Threading; using AvaloniaEdit.Utils; namespace AvaloniaEdit.CodeCompletion @@ -321,7 +322,7 @@ namespace AvaloniaEdit.CodeCompletion _currentList = listBoxItems; //_listBox.Items = null; Makes no sense? Tooltip disappeared because of this _listBox.ItemsSource = listBoxItems; - SelectIndexCentered(bestIndex); + Dispatcher.UIThread.Post(() => { SelectIndexCentered(bestIndex); }, DispatcherPriority.Loaded); } ///