Table of Contents

Class StyledNodeRendererBase

Namespace
FlowGraph.Avalonia.Rendering.NodeRenderers
Assembly
FlowGraph.Avalonia.dll

Base class for styled node renderers with icon and label support. Provides customizable colors, icons (text or geometry), and inline editing.

Override the abstract properties to customize appearance: - DefaultLabel: Default text when no label is set - GetNodeBackground(ThemeResources), GetNodeBorder(ThemeResources): Node colors - GetIconForeground(ThemeResources), GetTextForeground(ThemeResources): Text/icon colors

For icons, override ONE of: - IconText: Simple text icon (e.g., ">", "O", "?") - IconGeometry: Vector path for scalable icons (compatible with any icon library)

Using a Lucide icon path:
// Get path data from any icon library (Lucide, Material, etc.)
protected override Geometry? IconGeometry => 
    Geometry.Parse("M5 12h14M12 5l7 7-7 7"); // arrow-right
public abstract class StyledNodeRendererBase : DefaultNodeRenderer, IEditableNodeRenderer, INodeRenderer
Inheritance
StyledNodeRendererBase
Implements
Derived
Inherited Members

Fields

IconTag

Tag used to identify the icon element.

protected const string IconTag = "NodeIcon"

Field Value

string

LabelTag

Tag used to identify the label TextBlock.

protected const string LabelTag = "NodeLabel"

Field Value

string

Properties

DefaultLabel

Gets the default label when no label or data is set.

protected abstract string DefaultLabel { get; }

Property Value

string

IconGeometry

Gets the geometry for a vector icon. This takes precedence over IconText. Use this to integrate with any icon library (Lucide, Material, FontAwesome, etc.) by providing the icon's path data.

// Simple arrow icon
protected override Geometry? IconGeometry => 
    Geometry.Parse("M5 12h14M12 5l7 7-7 7");

// Or use a static geometry for better performance
private static readonly Geometry _icon = Geometry.Parse("M5 12h14");
protected override Geometry? IconGeometry => _icon;
protected virtual Geometry? IconGeometry { get; }

Property Value

Geometry

IconSize

Gets the icon size in canvas units (before scaling). Default is 16.

protected virtual double IconSize { get; }

Property Value

double

IconText

Gets the text icon to display (e.g., ">", "O", "?"). Override IconGeometry instead for vector icons. Default is null (no text icon).

protected virtual string? IconText { get; }

Property Value

string

Methods

BeginEdit(Control, Node, NodeRenderContext, Action<string>, Action)

Enters edit mode - replaces the label TextBlock with a TextBox.

public override void BeginEdit(Control visual, Node node, NodeRenderContext context, Action<string> onCommit, Action onCancel)

Parameters

visual Control
node Node
context NodeRenderContext
onCommit Action<string>
onCancel Action

CreateIconElement(NodeRenderContext)

Creates the icon element based on IconGeometry or IconText.

protected virtual Control? CreateIconElement(NodeRenderContext context)

Parameters

context NodeRenderContext

Returns

Control

CreateNodeContent(Node, NodeRenderContext)

Creates the content inside the node. Override to customize.

protected override Control CreateNodeContent(Node node, NodeRenderContext context)

Parameters

node Node
context NodeRenderContext

Returns

Control

CreateNodeVisual(Node, NodeRenderContext)

Creates the visual representation for a node.

public override Control CreateNodeVisual(Node node, NodeRenderContext context)

Parameters

node Node

The node data to render.

context NodeRenderContext

The rendering context with theme, scale, and settings.

Returns

Control

A Control representing the node visual.

EndEdit(Control, Node, NodeRenderContext)

Exits edit mode - removes the TextBox and shows the label.

public override void EndEdit(Control visual, Node node, NodeRenderContext context)

Parameters

visual Control
node Node
context NodeRenderContext

FindStackPanelContent(Control)

Finds the StackPanel content in the node visual.

protected StackPanel? FindStackPanelContent(Control visual)

Parameters

visual Control

Returns

StackPanel

GetDisplayText(Node)

Gets the display text for the node. Override to customize.

protected override string GetDisplayText(Node node)

Parameters

node Node

Returns

string

GetEditableText(Node)

Gets the text to edit. Override to customize.

protected override string GetEditableText(Node node)

Parameters

node Node

Returns

string

GetIconForeground(ThemeResources)

Gets the icon foreground brush for this node type.

protected abstract IBrush GetIconForeground(ThemeResources theme)

Parameters

theme ThemeResources

Returns

IBrush

GetNodeBackground(ThemeResources)

Gets the background brush for this node type.

protected abstract IBrush GetNodeBackground(ThemeResources theme)

Parameters

theme ThemeResources

Returns

IBrush

GetNodeBorder(ThemeResources)

Gets the border brush for this node type (when not selected).

protected abstract IBrush GetNodeBorder(ThemeResources theme)

Parameters

theme ThemeResources

Returns

IBrush

GetTextForeground(ThemeResources)

Gets the text foreground brush for this node type.

protected abstract IBrush GetTextForeground(ThemeResources theme)

Parameters

theme ThemeResources

Returns

IBrush

IsEditing(Control)

Gets whether the node is currently in edit mode.

public override bool IsEditing(Control visual)

Parameters

visual Control

Returns

bool

UpdateSelection(Control, Node, NodeRenderContext)

Updates the visual state when selection changes.

public override void UpdateSelection(Control visual, Node node, NodeRenderContext context)

Parameters

visual Control

The node's visual control.

node Node

The node data.

context NodeRenderContext

The rendering context.