IBlockPropertyAction<T> Interface
Definition
Action that operates on block-level properties (Paragraph, Section, etc.).
public interface IBlockPropertyAction<T>
Remarks
Block-level actions differ from inline actions in several ways:
- They operate on container elements (Block) rather than text runs (RichInline)
- They can affect multiple blocks in a selection
- They need to handle mixed values when multiple blocks have different property values
Common block properties include: TextAlignment, LineHeight, Margin, Padding, Background, BorderThickness, BorderBrush
Methods
| Name | Description |
|---|---|
| GetAvailableValues | Gets available values for the property (e.g., TextAlignment values). |
| GetValue | Gets the property value from the current block(s). |
| SetValue | Sets the property value on all affected blocks. |
GetAvailableValues Method
Gets available values for the property (e.g., TextAlignment values).
public System.Collections.Generic.IEnumerable<T> GetAvailableValues()
Returns
System.Collections.Generic.IEnumerable<T>
A collection of possible values, or null if the property doesn't have a fixed set of choices (e.g., for numeric properties like Margin).
Remarks
Used by UI controls (ComboBox) to populate the list of options. For example, TextAlignment returns [Left, Center, Right, Justify].
GetValue Method
Gets the property value from the current block(s).
public T GetValue(Avalonia.Controls.Documents.Primitives.ITextEditorHost host)
Parameters
host Avalonia.Controls.Documents.Primitives.ITextEditorHost
The editor host.
Returns
T
The property value if all affected blocks have the same value. Returns null (or default) if blocks have mixed values.
Remarks
For collapsed selections (caret), returns the value from the containing block. For range selections, returns the consistent value or null if blocks have different values.
SetValue Method
Sets the property value on all affected blocks.
public void SetValue(Avalonia.Controls.Documents.Primitives.ITextEditorHost host, T value)
Parameters
host Avalonia.Controls.Documents.Primitives.ITextEditorHost
The editor host.
value T
The value to set.
Remarks
This method applies the property to all blocks in the current selection. For collapsed selections, affects only the containing block. For range selections, affects all blocks from Start to End.
The operation should be wrapped in an undo unit to allow undoing the entire multi-block change as a single operation.