diff --git a/src/modules/cmdpal/Core/Microsoft.CmdPal.Core.ViewModels/ContextMenuViewModel.cs b/src/modules/cmdpal/Core/Microsoft.CmdPal.Core.ViewModels/ContextMenuViewModel.cs index 0263f20464..07c238ab42 100644 --- a/src/modules/cmdpal/Core/Microsoft.CmdPal.Core.ViewModels/ContextMenuViewModel.cs +++ b/src/modules/cmdpal/Core/Microsoft.CmdPal.Core.ViewModels/ContextMenuViewModel.cs @@ -53,7 +53,7 @@ public partial class ContextMenuViewModel : ObservableObject, { if (SelectedItem is not null) { - if (SelectedItem.MoreCommands.Count() > 1) + if (SelectedItem.PrimaryCommand is not null || SelectedItem.HasMoreCommands) { ContextMenuStack.Clear(); PushContextStack(SelectedItem.AllCommands); diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/CommandBar.xaml.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/CommandBar.xaml.cs index 5666381d82..133a9364f0 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/CommandBar.xaml.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/CommandBar.xaml.cs @@ -44,13 +44,14 @@ public sealed partial class CommandBar : UserControl, public void Receive(OpenContextMenuMessage message) { - if (!ViewModel.ShouldShowContextMenu) - { - return; - } - if (message.Element is null) { + // This is invoked from the "More" button on the command bar + if (!ViewModel.ShouldShowContextMenu) + { + return; + } + _ = DispatcherQueue.TryEnqueue( () => { @@ -65,6 +66,7 @@ public sealed partial class CommandBar : UserControl, } else { + // This is invoked from a specific element _ = DispatcherQueue.TryEnqueue( () => {