Table of Contents

Interface ICommandContext

Namespace
Terminal.Gui.Input
Assembly
Terminal.Gui.dll

Describes the context in which a Command is being invoked. When a Command is invoked via InvokeCommand(Command) a context object is passed to Command handlers as an ICommandContext reference.

public interface ICommandContext
Extension Methods

Properties

Binding

The binding that triggered the command.

Command

The Command that is being invoked.

Routing

Gets the routing mode for this command invocation.

Source

A weak reference to the View that was the source of the command invocation, if any. (e.g. the view the user clicked on or the view that had focus when a key was pressed). Use Source?.TryGetTarget(out View? view) to safely access the source view.

Value

Gets the most recently appended value from Values, or null if Values is empty. This is a convenience accessor equivalent to Values.Count > 0 ? Values[^1] : null.

Values

Gets all values accumulated as the command propagated up the view hierarchy. Each IValue-implementing view in the chain appends its value via GetValue() as the command bubbles up. The list is ordered from innermost (originator) to outermost (last composite to append).

See Also