Docsv3.31.0
Back to API Reference
Class

ToggleStyleCommand

Inherits:TextCommand

Toggles one of the field's own styles on the selection, or as the typing style at a caret, in that style's markup syntax — bold unless another style is chosen. Applies while the field is editable and carries a style the source can toggle; its default title is the style's own label.

public IFormatStyleSource Style{ get; set }

Style the command toggles, resolved among the styles the field carries; unassigned never applies.

protected string DefaultTitle{ get }

Label shown while no title is set — by default the type name in sentence case without its Command suffix, so SearchWebCommand reads "Search web".

[ctor]public ToggleStyleCommand()

Creates the command toggling the field's bold style.

[ctor]public ToggleStyleCommand(string title, IFormatStyleSource style)

Creates a command titled title that toggles the style style resolves.

public override bool IsApplicable(in TextCommandContext context)

Whether the command applies to the field's current state. A menu hides or disables a command that does not apply, and a command runs only while it applies.

public override bool IsActive(in TextCommandContext context)

Whether the command's effect is on at the field's selection, for a control that shows it as pressed — a style toggle reports whether its style is active. False for a command that toggles nothing.

public override void Execute(in TextCommandContext context)

Runs the command against the field's current state, to which it applies (IsApplicable).

public override bool Matches(TextCommand command)

Whether command is this command, as a menu item bound to this command matches the field's (ContextMenuItem.Command): by default, a command of this type or one derived from it. The title plays no part; a command whose settings decide its effect compares them too, as a style toggle compares its style.