This commit is contained in:
Yu Leng (from Dev Box)
2025-07-17 17:03:54 +08:00
parent 6642c805b7
commit 782ee47ecd
3 changed files with 27 additions and 2 deletions

View File

@@ -63,9 +63,13 @@ public sealed partial class TopLevelViewModel : ObservableObject, IListItem
{ {
return item as IContextItem; return item as IContextItem;
} }
else if (item is CommandContextItemViewModel commandItem)
{
return commandItem.Model.Unsafe;
}
else else
{ {
return ((CommandContextItemViewModel)item).Model.Unsafe; return null;
} }
}).ToArray(); }).ToArray();

View File

@@ -33,9 +33,14 @@ internal sealed partial class ContextItemTemplateSelector : DataTemplateSelector
li.AllowFocusOnInteraction = false; li.AllowFocusOnInteraction = false;
dataTemplate = Separator; dataTemplate = Separator;
} }
else if (item is CommandContextItemViewModel commandItem)
{
dataTemplate = commandItem.IsCritical ? Critical : Default;
}
else else
{ {
dataTemplate = ((CommandContextItemViewModel)item).IsCritical ? Critical : Default; // Fallback for unknown types
dataTemplate = Default;
} }
} }

View File

@@ -2,6 +2,22 @@
<Application> <Application>
<Assembly Name="Microsoft.WinUI"> <Assembly Name="Microsoft.WinUI">
<Type Name="Microsoft.UI.Xaml.Controls.FontIconSource" Dynamic="Required All" /> <Type Name="Microsoft.UI.Xaml.Controls.FontIconSource" Dynamic="Required All" />
<Type Name="Microsoft.UI.Xaml.DataTemplate" Dynamic="Required All" />
<Type Name="Microsoft.UI.Xaml.Controls.DataTemplateSelector" Dynamic="Required All" />
<Type Name="Microsoft.UI.Xaml.Controls.ListViewItem" Dynamic="Required All" />
</Assembly>
<!-- Add ViewModel types for AOT compatibility -->
<Assembly Name="Microsoft.CmdPal.Core.ViewModels">
<Type Name="Microsoft.CmdPal.Core.ViewModels.CommandContextItemViewModel" Dynamic="Required All" />
<Type Name="Microsoft.CmdPal.Core.ViewModels.SeparatorContextItemViewModel" Dynamic="Required All" />
<Type Name="Microsoft.CmdPal.Core.ViewModels.IContextItemViewModel" Dynamic="Required All" />
<Type Name="Microsoft.CmdPal.Core.ViewModels.CommandItemViewModel" Dynamic="Required All" />
</Assembly>
<!-- Add UI types for AOT compatibility -->
<Assembly Name="Microsoft.CmdPal.UI">
<Type Name="Microsoft.CmdPal.UI.ContextItemTemplateSelector" Dynamic="Required All" />
</Assembly> </Assembly>
</Application> </Application>
</Directives> </Directives>