Skip to main content

NumberedMarkerStyleAction Class

Definition

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

Action for changing the Avalonia.Controls.Documents.Primitives.DocumentNodes.TextMarkerStyle of numbered (ordered) lists.

public class NumberedMarkerStyleAction

Inheritance: object -> EditorAction -> NumberedMarkerStyleAction

Implements: IBlockPropertyAction, IBlockPropertyAction<TextMarkerStyle>, IEditorAction, IPropertyAction

Remarks

Avalonia.Controls.Documents.Primitives.Actions.NumberedMarkerStyleAction.CanExecute(Avalonia.Controls.Documents.Primitives.ITextEditorHost) returns true only when the caret is inside a numbered Avalonia.Controls.Documents.List (Decimal, LowerLatin, UpperLatin, LowerRoman, UpperRoman). Avalonia.Controls.Documents.Primitives.Actions.NumberedMarkerStyleAction.GetAvailableValues returns only the numbered marker styles.

Constructors

NameDescription
NumberedMarkerStyleActionNo summary available.

NumberedMarkerStyleAction Constructor

public NumberedMarkerStyleAction()

Methods

NameDescription
CanExecuteGets whether the action can currently execute.
ExecuteExecutes the action synchronously.
GetAvailableValuesReturns numbered Avalonia.Controls.Documents.Primitives.DocumentNodes.TextMarkerStyle values.
GetStateGets the current state of the action.
GetValueGets the current marker style of the first numbered list containing the caret/selection.
HasConsistentValueGets whether all affected blocks have the same value for this property.
SetValueSets the marker style on all numbered lists covering the selection.
ExecuteAsyncExecutes the action asynchronously. Inherited from EditorAction.

CanExecute Method

Gets whether the action can currently execute.

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

Parameters

host Avalonia.Controls.Documents.Primitives.ITextEditorHost

The editor host to check against.

Returns

bool

True if the action can execute; otherwise, false.

Remarks

This is called frequently to update UI state (button enabled/disabled). Implementations should be fast and avoid heavy computation.

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

Returns numbered Avalonia.Controls.Documents.Primitives.DocumentNodes.TextMarkerStyle values.

public System.Collections.Generic.IEnumerable<Avalonia.Controls.Documents.Primitives.DocumentNodes.TextMarkerStyle> GetAvailableValues()

Returns

System.Collections.Generic.IEnumerable<Avalonia.Controls.Documents.Primitives.DocumentNodes.TextMarkerStyle>

GetState Method

Gets the current state of the action.

public object GetState(Avalonia.Controls.Documents.Primitives.ITextEditorHost host)

Parameters

host Avalonia.Controls.Documents.Primitives.ITextEditorHost

The editor host to query.

Returns

object

The current state, or null if the action has no state. For toggle actions, this returns a boolean. For property actions, this returns the current property value.

GetValue Method

Gets the current marker style of the first numbered list containing the caret/selection.

public Avalonia.Controls.Documents.Primitives.DocumentNodes.TextMarkerStyle GetValue(Avalonia.Controls.Documents.Primitives.ITextEditorHost host)

Parameters

host Avalonia.Controls.Documents.Primitives.ITextEditorHost

Returns

Avalonia.Controls.Documents.Primitives.DocumentNodes.TextMarkerStyle

HasConsistentValue Method

Gets whether all affected blocks have the same value for this property.

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

Parameters

host Avalonia.Controls.Documents.Primitives.ITextEditorHost

The editor host.

Returns

bool

True if all affected blocks have the same property value. False if blocks have different values (mixed state).

Remarks

UI controls should show a mixed/indeterminate state when this returns false. For example, a ComboBox might show "Mixed" placeholder text.

For collapsed selections, this always returns true (single block).

SetValue Method

Sets the marker style on all numbered lists covering the selection.

public void SetValue(Avalonia.Controls.Documents.Primitives.ITextEditorHost host, Avalonia.Controls.Documents.Primitives.DocumentNodes.TextMarkerStyle value)

Parameters

host Avalonia.Controls.Documents.Primitives.ITextEditorHost

value Avalonia.Controls.Documents.Primitives.DocumentNodes.TextMarkerStyle

Properties

NameDescription
DisplayNameGets the display name for UI purposes.
IdGets the unique identifier for this action.
GestureGets the optional keyboard gesture for this action. Inherited from EditorAction.

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.RichBold, Format.RichItalic, etc.
  • Paragraph.AlignLeft, Paragraph.BulletList, etc.