Struct CommandContext
Provides context for a Command invocation.
public struct CommandContext : ICommandContext, IEquatable<CommandContext>
- Implements
- Inherited Members
- Extension Methods
Remarks
Use pattern matching to access specific binding types:
if (ctx.Binding is KeyBinding kb) { /* key input */ }
else if (ctx.Binding is MouseBinding mb) { /* mouse input */ }
else if (ctx.Binding is InputBinding ib) { /* programmatic */ }
Constructors
- CommandContext(Command, WeakReference<View>?, IInputBinding?)
Initializes a new instance with the specified Command.
Properties
- Binding
The binding that triggered the command.
- 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.