From d5a68b4b22c9719251830feb217e5b16a51f5385 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Thu, 23 Feb 2023 23:38:38 +0100 Subject: [PATCH] Ensure layout before trying to move selection. --- src/Avalonia.Controls/MenuItem.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Avalonia.Controls/MenuItem.cs b/src/Avalonia.Controls/MenuItem.cs index 5588bde7c0..5c9dd4e193 100644 --- a/src/Avalonia.Controls/MenuItem.cs +++ b/src/Avalonia.Controls/MenuItem.cs @@ -309,7 +309,12 @@ namespace Avalonia.Controls protected override bool IsEnabledCore => base.IsEnabledCore && _commandCanExecute; /// - bool IMenuElement.MoveSelection(NavigationDirection direction, bool wrap) => MoveSelection(direction, wrap); + bool IMenuElement.MoveSelection(NavigationDirection direction, bool wrap) + { + if (Presenter?.Panel is null) + (VisualRoot as ILayoutRoot)?.LayoutManager.ExecuteLayoutPass(); + return MoveSelection(direction, wrap); + } /// IMenuItem? IMenuElement.SelectedItem