BlockAdorner Class
Definition
Base class for editor-driven block decorations that participate in the Avalonia property system and logical tree.
public class BlockAdorner
Remarks
Subclasses decorate realized Avalonia.Controls.Documents.Primitives.DocumentNodes.DocumentNode instances without modifying the block data model. A single adorner can provide immediate-mode rendering via Avalonia.Controls.Documents.Primitives.Adorners.BlockAdorner.Render(Avalonia.Media.DrawingContext,Avalonia.Controls.Documents.Primitives.DocumentNodes.DocumentNode,Avalonia.Rect), interactive controls via Avalonia.Controls.Documents.Primitives.Adorners.BlockAdorner.CreateControl(Avalonia.Controls.Documents.Primitives.DocumentNodes.DocumentNode)/Avalonia.Controls.Documents.Primitives.Adorners.BlockAdorner.UpdateControl(Avalonia.Controls.Control,Avalonia.Controls.Documents.Primitives.DocumentNodes.DocumentNode,Avalonia.Rect), or both.
Each adorner declares which block categories it targets via Avalonia.Controls.Documents.Primitives.Adorners.BlockAdorner.TargetAreas and whether it renders on all matching blocks or only the current context block via Avalonia.Controls.Documents.Primitives.Adorners.BlockAdorner.Visibility.
Because Avalonia.Controls.Documents.Primitives.Adorners.BlockAdorner extends Avalonia.StyledElement, adorners added to a Avalonia.Controls.Documents.Primitives.Adorners.BlockAdornerLayer join its logical tree and can receive styles and dynamic resources from ancestor resource dictionaries.
Methods
| Name | Description |
|---|---|
| ApplyStyling | Applies styling to the control if the control is initialized and styling is not already applied. Inherited from StyledElement. |
| BeginInit | Inherited from StyledElement. |
| Bind (8 overloads) | Binds a Avalonia.AvaloniaProperty to an Avalonia.Data.BindingBase. Inherited from AvaloniaObject. |
| CheckAccess | Returns a value indicating whether the current thread is the UI thread. Inherited from AvaloniaObject. |
| ClearValue (4 overloads) | Clears a Avalonia.AvaloniaProperty's local value. Inherited from AvaloniaObject. |
| CoerceValue | Coerces the specified Avalonia.AvaloniaProperty. Inherited from AvaloniaObject. |
| CreateControl | Creates an interactive control overlaid on a document node, or returns null if this adorner has no interactive component. Called once per (adorner, node) pair when the node first becomes realized and passes all filters. |
| EndInit | Inherited from StyledElement. |
| Equals | Compares two objects using reference equality. Inherited from AvaloniaObject. |
| GetBaseValue | Inherited from AvaloniaObject. |
| GetHashCode | Gets the hash code for the object. Inherited from AvaloniaObject. |
| GetValue (3 overloads) | Gets a Avalonia.AvaloniaProperty value. Inherited from AvaloniaObject. |
| IsAnimating | Checks whether a Avalonia.AvaloniaProperty is animating. Inherited from AvaloniaObject. |
| IsSet | Checks whether a Avalonia.AvaloniaProperty is set on this object. Inherited from AvaloniaObject. |
| Render | Draws the immediate-mode decoration for a single block. Adorners that only provide interactive controls can leave this as a no-op. |
| SetCurrentValue (2 overloads) | Sets the value of a dependency property without changing its value source. Inherited from AvaloniaObject. |
| SetValue (3 overloads) | Sets a Avalonia.AvaloniaProperty value. Inherited from AvaloniaObject. |
| ShouldRender | Performs a final per-node check after target-area and visibility filtering has passed. Use this for fine-grained logic such as skipping blocks that already have visible borders. |
| TryGetResource | Inherited from StyledElement. |
| UpdateControl | Updates an interactive control's state after a layout pass. Only called when Avalonia.Controls.Documents.Primitives.Adorners.BlockAdorner.CreateControl(Avalonia.Controls.Documents.Primitives.DocumentNodes.DocumentNode) previously returned a non-null value for this node. |
| VerifyAccess | Checks that the current thread is the UI thread and throws if not. Inherited from AvaloniaObject. |
CreateControl Method
Creates an interactive control overlaid on a document node, or
returns null if this adorner has no interactive component.
Called once per (adorner, node) pair when the node first becomes
realized and passes all filters.
public Avalonia.Controls.Control CreateControl(Avalonia.Controls.Documents.Primitives.DocumentNodes.DocumentNode node)
Parameters
node Avalonia.Controls.Documents.Primitives.DocumentNodes.DocumentNode
The realized document node to adorn.
Returns
A new control, or null for non-interactive adorners.
Render Method
Draws the immediate-mode decoration for a single block. Adorners that only provide interactive controls can leave this as a no-op.
public void Render(Avalonia.Media.DrawingContext context, Avalonia.Controls.Documents.Primitives.DocumentNodes.DocumentNode node, Avalonia.Rect blockBounds)
Parameters
context Avalonia.Media.DrawingContext
The drawing context, already transformed into text-view coordinates.
node Avalonia.Controls.Documents.Primitives.DocumentNodes.DocumentNode
The realized document node being decorated.
blockBounds Avalonia.Rect
The node bounds in text-view coordinates.
ShouldRender Method
Performs a final per-node check after target-area and visibility filtering has passed. Use this for fine-grained logic such as skipping blocks that already have visible borders.
public bool ShouldRender(Avalonia.Controls.Documents.Primitives.DocumentNodes.DocumentNode node)
Parameters
node Avalonia.Controls.Documents.Primitives.DocumentNodes.DocumentNode
The realized document node to test.
Returns
bool
true if the adorner should render for this node.
UpdateControl Method
Updates an interactive control's state after a layout pass. Only called when Avalonia.Controls.Documents.Primitives.Adorners.BlockAdorner.CreateControl(Avalonia.Controls.Documents.Primitives.DocumentNodes.DocumentNode) previously returned a non-null value for this node.
public void UpdateControl(Avalonia.Controls.Control control, Avalonia.Controls.Documents.Primitives.DocumentNodes.DocumentNode node, Avalonia.Rect blockBounds)
Parameters
control Avalonia.Controls.Control
The control previously returned by Avalonia.Controls.Documents.Primitives.Adorners.BlockAdorner.CreateControl(Avalonia.Controls.Documents.Primitives.DocumentNodes.DocumentNode).
node Avalonia.Controls.Documents.Primitives.DocumentNodes.DocumentNode
The realized document node.
blockBounds Avalonia.Rect
The node bounds in text-view coordinates.
Properties
| Name | Description |
|---|---|
| ActualThemeVariant | Gets the UI theme that is currently used by the element, which might be different than the RequestedThemeVariantProperty. Inherited from StyledElement. |
| Classes | Gets or sets the styled element's classes. Inherited from StyledElement. |
| DataContext | Gets or sets the control's data context. Inherited from StyledElement. |
| Dispatcher | Returns the Avalonia.AvaloniaObject.Dispatcher that this Avalonia.AvaloniaObject is associated with. Inherited from AvaloniaObject. |
| IsEnabled | Gets or sets whether this adorner takes part in rendering. When false, the layer skips it entirely. |
| IsInitialized | Gets a value that indicates whether the element has finished initialization. Inherited from StyledElement. |
| Item | Inherited from AvaloniaObject. |
| Name | Gets or sets the name of the styled element. Inherited from StyledElement. |
| Parent | Gets the styled element's logical parent. Inherited from StyledElement. |
| Resources | Gets or sets the styled element's resource dictionary. Inherited from StyledElement. |
| StyleKey | Gets the type by which the element is styled. Inherited from StyledElement. |
| Styles | Gets the styles for the styled element. Inherited from StyledElement. |
| TargetAreas | Gets which block categories this adorner targets. The layer skips blocks whose resolved category does not intersect with this value. |
| TemplatedParent | Gets the styled element whose lookless template this styled element is part of. Inherited from StyledElement. |
| Theme | Gets or sets the theme to be applied to the element. Inherited from StyledElement. |
| Transitions | Gets or sets the property transitions for the control. Inherited from Animatable. |
| Visibility | Gets or sets whether this adorner renders on every matching block or only on the current context block. |
| ZIndex | Gets or sets the Z-index for render ordering among adorners. Higher values render on top. |
IsEnabled Property
Gets or sets whether this adorner takes part in rendering.
When false, the layer skips it entirely.
public bool IsEnabled { get; set; }
TargetAreas Property
Gets which block categories this adorner targets. The layer skips blocks whose resolved category does not intersect with this value.
public Avalonia.Controls.Documents.Primitives.Adorners.ToolbarTargetAreas TargetAreas { get; set; }
Visibility Property
Gets or sets whether this adorner renders on every matching block or only on the current context block.
public Avalonia.Controls.Documents.Primitives.Adorners.BlockAdornerVisibility Visibility { get; set; }
ZIndex Property
Gets or sets the Z-index for render ordering among adorners. Higher values render on top.
public int ZIndex { get; set; }
Fields
| Name | Description |
|---|---|
| DataContextProperty | Defines the Avalonia.StyledElement.DataContext property. Inherited from StyledElement. |
| IsEnabledProperty | Defines the Avalonia.Controls.Documents.Primitives.Adorners.BlockAdorner.IsEnabled property. |
| NameProperty | Defines the Avalonia.StyledElement.Name property. Inherited from StyledElement. |
| ParentProperty | Defines the Avalonia.StyledElement.Parent property. Inherited from StyledElement. |
| TemplatedParentProperty | Defines the Avalonia.StyledElement.TemplatedParent property. Inherited from StyledElement. |
| ThemeProperty | Defines the Avalonia.StyledElement.Theme property. Inherited from StyledElement. |
| TransitionsProperty | Defines the Avalonia.Animation.Animatable.Transitions property. Inherited from Animatable. |
| VisibilityProperty | Defines the Avalonia.Controls.Documents.Primitives.Adorners.BlockAdorner.Visibility property. |
| ZIndexProperty | Defines the Avalonia.Controls.Documents.Primitives.Adorners.BlockAdorner.ZIndex property. |
IsEnabledProperty Field
Defines the Avalonia.Controls.Documents.Primitives.Adorners.BlockAdorner.IsEnabled property.
public Avalonia.StyledProperty<bool> IsEnabledProperty
VisibilityProperty Field
Defines the Avalonia.Controls.Documents.Primitives.Adorners.BlockAdorner.Visibility property.
public Avalonia.StyledProperty<Avalonia.Controls.Documents.Primitives.Adorners.BlockAdornerVisibility> VisibilityProperty
ZIndexProperty Field
Defines the Avalonia.Controls.Documents.Primitives.Adorners.BlockAdorner.ZIndex property.
public Avalonia.StyledProperty<int> ZIndexProperty
Events
| Name | Description |
|---|---|
| ActualThemeVariantChanged | Raised when the theme variant is changed on the element or an ancestor of the element. Inherited from StyledElement. |
| AttachedToLogicalTree | Raised when the styled element is attached to a rooted logical tree. Inherited from StyledElement. |
| Changed | Raised when the adorner's visual state changes and the layer should repaint. |
| DataContextChanged | Occurs when the Avalonia.StyledElement.DataContext property changes. Inherited from StyledElement. |
| DetachedFromLogicalTree | Raised when the styled element is detached from a rooted logical tree. Inherited from StyledElement. |
| Initialized | Occurs when the styled element has finished initialization. Inherited from StyledElement. |
| PropertyChanged | Raised when a Avalonia.AvaloniaProperty value changes on this object. Inherited from AvaloniaObject. |
| ResourcesChanged | Occurs when a resource in this styled element or a parent styled element has changed. Inherited from StyledElement. |
Changed Event
Raised when the adorner's visual state changes and the layer should repaint.
public event EventHandler Changed