CmdPal: try to fix the context menu crash, again. (#40814)

Cherry-pick of 782ee47. That is probably over-aggressive, but it fixes
it.

Closes  #40633
previously: #40744

---------

Co-authored-by: Yu Leng (from Dev Box) <yuleng@microsoft.com>
This commit is contained in:
Mike Griese
2025-07-28 08:32:08 -05:00
committed by GitHub
parent 81a7b81927
commit 858081ec78
3 changed files with 24 additions and 2 deletions

View File

@@ -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;
}
}