mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 02:36:19 +02:00
CmdPal: Use a factory for building the context menu VMs (#45572)
_targets #45566_ doesn't actually do anything, just moves around the instantiation of command context item VMs. This will let use add pin/unpin commands later related to https://github.com/microsoft/PowerToys/issues/45191 related to https://github.com/microsoft/PowerToys/issues/45201
This commit is contained in:
@@ -9,11 +9,11 @@ using Microsoft.CommandPalette.Extensions;
|
||||
namespace Microsoft.CmdPal.UI.ViewModels;
|
||||
|
||||
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]
|
||||
public partial class CommandContextItemViewModel(ICommandContextItem contextItem, WeakReference<IPageContext> context) : CommandItemViewModel(new(contextItem), context), IContextItemViewModel
|
||||
public partial class CommandContextItemViewModel : CommandItemViewModel, IContextItemViewModel
|
||||
{
|
||||
private readonly KeyChord nullKeyChord = new(0, 0, 0);
|
||||
|
||||
public new ExtensionObject<ICommandContextItem> Model { get; } = new(contextItem);
|
||||
public new ExtensionObject<ICommandContextItem> Model { get; }
|
||||
|
||||
public bool IsCritical { get; private set; }
|
||||
|
||||
@@ -21,6 +21,13 @@ public partial class CommandContextItemViewModel(ICommandContextItem contextItem
|
||||
|
||||
public bool HasRequestedShortcut => RequestedShortcut is not null && (RequestedShortcut.Value != nullKeyChord);
|
||||
|
||||
public CommandContextItemViewModel(ICommandContextItem contextItem, WeakReference<IPageContext> context)
|
||||
: base(new(contextItem), context)
|
||||
{
|
||||
Model = new(contextItem);
|
||||
IsContextMenuItem = true;
|
||||
}
|
||||
|
||||
public override void InitializeProperties()
|
||||
{
|
||||
if (IsInitialized)
|
||||
|
||||
Reference in New Issue
Block a user