diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/TopLevelViewModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/TopLevelViewModel.cs index dabfdca3f6..6d78d95180 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/TopLevelViewModel.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/TopLevelViewModel.cs @@ -63,9 +63,13 @@ public sealed partial class TopLevelViewModel : ObservableObject, IListItem { return item as IContextItem; } + else if (item is CommandContextItemViewModel commandItem) + { + return commandItem.Model.Unsafe; + } else { - return ((CommandContextItemViewModel)item).Model.Unsafe; + return null; } }).ToArray(); diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Converters/ContextItemTemplateSelector.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI/Converters/ContextItemTemplateSelector.cs index d2af6ca6d6..aec50163db 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Converters/ContextItemTemplateSelector.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Converters/ContextItemTemplateSelector.cs @@ -33,9 +33,14 @@ internal sealed partial class ContextItemTemplateSelector : DataTemplateSelector li.AllowFocusOnInteraction = false; dataTemplate = Separator; } + else if (item is CommandContextItemViewModel commandItem) + { + dataTemplate = commandItem.IsCritical ? Critical : Default; + } else { - dataTemplate = ((CommandContextItemViewModel)item).IsCritical ? Critical : Default; + // Fallback for unknown types + dataTemplate = Default; } } diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/rd.xml b/src/modules/cmdpal/Microsoft.CmdPal.UI/rd.xml index f8dc5641af..3a0f03917f 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/rd.xml +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/rd.xml @@ -2,6 +2,22 @@ + + + + + + + + + + + + + + + +