Skip to main content

TextAlignmentToggleAction Class

Definition​

Assembly:Avalonia.Controls.RichTextEditor
Package:Avalonia.Controls.RichTextEditor

Action for setting a specific text alignment on block elements.

public class TextAlignmentToggleAction

Inheritance: BlockPropertyAction<TextAlignment> -> TextAlignmentToggleAction

Constructors​

NameDescription
TextAlignmentToggleActionInitializes a new instance for the given alignment with an explicit name.

TextAlignmentToggleAction Constructor​

Initializes a new instance for the given alignment with an explicit name.

public TextAlignmentToggleAction(Avalonia.Media.TextAlignment value, string idSuffix, string displayName)

Parameters​

value Avalonia.Media.TextAlignment

The alignment this action applies.

idSuffix string

Suffix appended to the action identifier (e.g. "Left").

displayName string

Human-readable name shown in tooltips and menus.

Remarks​

Use the Avalonia.Controls.Documents.Primitives.Actions.EditorActions singleton for the alignment. A suffix that no built-in action carries leaves the instance unreachable through Avalonia.Controls.Documents.Primitives.Actions.EditorActions.GetById(string).

Methods​

NameDescription
ExecuteExecutes the action synchronously.
GetAvailableValuesNo summary available.
IsCheckedGets whether the action is currently "on" for the selection.

Execute Method​

Executes the action synchronously.

public void Execute(Avalonia.Controls.Documents.Primitives.ITextEditorHost host)

Parameters​

host Avalonia.Controls.Documents.Primitives.ITextEditorHost

The editor host to execute on.

Remarks​

For actions that require async operations (like file dialogs), use Avalonia.Controls.Documents.Primitives.Actions.IEditorAction.ExecuteAsync(Avalonia.Controls.Documents.Primitives.ITextEditorHost) instead.

GetAvailableValues Method​

public System.Collections.Generic.IEnumerable<Avalonia.Media.TextAlignment> GetAvailableValues()

Returns​

System.Collections.Generic.IEnumerable<Avalonia.Media.TextAlignment>

IsChecked Method​

Gets whether the action is currently "on" for the selection.

public bool IsChecked(Avalonia.Controls.Documents.Primitives.ITextEditorHost host)

Parameters​

host Avalonia.Controls.Documents.Primitives.ITextEditorHost

The editor host to query.

Returns​

bool

True if the toggle state is on; otherwise, false.

Remarks​

For formatting actions, this returns true if all text in the selection has the formatting applied.

Properties​

NameDescription
DisplayNameGets the display name for UI purposes.
IdGets the unique identifier for this action.

DisplayName Property​

Gets the display name for UI purposes.

public string DisplayName { get; set; }

Remarks​

This is used for tooltips, menu items, and accessibility.

Id Property​

Gets the unique identifier for this action.

public string Id { get; set; }

Remarks​

IDs follow a hierarchical naming convention: