TextAlignmentToggleAction Class
Definition
Action for setting a specific text alignment on block elements.
public class TextAlignmentToggleAction
Constructors
| Name | Description |
|---|---|
| TextAlignmentToggleAction | Initializes 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
| Name | Description |
|---|---|
| Execute | Executes the action synchronously. |
| GetAvailableValues | No summary available. |
| IsChecked | Gets 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
| Name | Description |
|---|---|
| DisplayName | Gets the display name for UI purposes. |
| Id | Gets 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:
- Edit.Undo, Edit.Redo, Edit.Cut, etc.
- Format.Bold, Format.Italic, etc.
- Block.TextAlignment.Left, List.ToggleBulletList, etc. Avalonia.Controls.Documents.Primitives.Actions.EditorActionIds names the identifier of every built-in action.