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)
This commit is contained in:
Daniel Peñalba 2024-11-05 17:11:33 +01:00
Родитель 478636e547
Коммит 3dbfd2303c
1 изменённых файлов: 2 добавлений и 1 удалений

Просмотреть файл

@ -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);
}
/// <summary>