Skip to content

Latest commit

 

History

History
86 lines (58 loc) · 2.43 KB

File metadata and controls

86 lines (58 loc) · 2.43 KB
title CommandContextItem Constructors
description Initializes a new instance of the CommandContextItem class.
ms.date 2/27/2025
ms.topic reference
no-loc
PowerToys
Windows
Insider

CommandContextItem Constructors

CommandContextItem(ICommand) Constructor

Definition

Namespace: Microsoft.CommandPalette.Extensions.Toolkit

Initializes a new instance of the CommandContextItem class from the base CommandItem class, setting its Command property to command.

public CommandContextItem(ICommand command)
        : base(command)
    {
    }

Parameters

command ICommand

The command to be associated with the command item. This parameter is required and cannot be null.

CommandContextItem(String, String, String, Action, ICommandResult) Constructor

Definition

Namespace: Microsoft.CommandPalette.Extensions.Toolkit

Initializes a new instance of the CommandContextItem class from the base CommandItem class, setting its Title property to title, its Subtitle to subtitle, and creates a new AnonymousCommand object with a name, action, and result.

public CommandContextItem(
        string title,
        string subtitle = "",
        string name = "",
        Action? action = null,
        ICommandResult? result = null)
    {
        var c = new AnonymousCommand(action);
        if (!string.IsNullOrEmpty(name))
        {
            c.Name = name;
        }

        if (result != null)
        {
            c.Result = result;
        }

        Command = c;

        Title = title;
        Subtitle = subtitle;
    }

Parameters

title String

The title of the command item.

subtitle String

The subtitle of the command item.

name String

The name of the command item.

action Action

The action to be performed when the command item is executed.

result ICommandResult

The result of the command item execution. This parameter is optional and can be null.