Table of Contents

Class HeaderedNodeRendererBase

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

Base class for nodes with a header section and content area (React Flow style). Structure: Outer border (rounded) -> Header (semi-transparent) + Body (solid white) Uses true container resize (like React Flow, Rete.js, Node-RED) - content stays fixed size, container grows/shrinks to provide more/less space.

public abstract class HeaderedNodeRendererBase : DataNodeRendererBase, IEditableNodeRenderer, IDataNodeRenderer, INodeRenderer
Inheritance
HeaderedNodeRendererBase
Implements
Derived
Inherited Members

Fields

BodyPanelTag

protected const string BodyPanelTag = "BodyPanel"

Field Value

string

ContentPanelTag

protected const string ContentPanelTag = "ContentPanel"

Field Value

string

HeaderLabelTag

protected const string HeaderLabelTag = "HeaderLabel"

Field Value

string

HeaderPanelTag

protected const string HeaderPanelTag = "HeaderPanel"

Field Value

string

MainPanelTag

protected const string MainPanelTag = "MainPanel"

Field Value

string

OuterBorderTag

protected const string OuterBorderTag = "OuterBorder"

Field Value

string

Properties

BorderThickness

Gets the border thickness for the outer node border.

protected virtual double BorderThickness { get; }

Property Value

double

ContentVerticalPadding

Vertical padding for content inside the body.

protected virtual double ContentVerticalPadding { get; }

Property Value

double

CornerRadius

The corner radius for the outer node border.

protected virtual double CornerRadius { get; }

Property Value

double

HeaderFontSize

The font size for the header label.

protected virtual double HeaderFontSize { get; }

Property Value

double

HeaderVerticalPadding

Vertical padding for the header area.

protected virtual double HeaderVerticalPadding { get; }

Property Value

double

HorizontalPadding

Horizontal padding for content inside the header and body.

protected virtual double HorizontalPadding { get; }

Property Value

double

SelectedBorderThickness

Gets the selected border thickness.

protected virtual double SelectedBorderThickness { get; }

Property Value

double

Methods

CreateContent(Node, INodeProcessor?, NodeRenderContext)

Creates the content area control(s).

protected abstract Control CreateContent(Node node, INodeProcessor? processor, NodeRenderContext context)

Parameters

node Node
processor INodeProcessor
context NodeRenderContext

Returns

Control

CreateDataBoundVisual(Node, INodeProcessor?, NodeRenderContext)

Creates the visual with data binding context.

public override Control CreateDataBoundVisual(Node node, INodeProcessor? processor, NodeRenderContext context)

Parameters

node Node

The node to render.

processor INodeProcessor

The node's data processor (may be null for display-only nodes).

context NodeRenderContext

The render context.

Returns

Control

A control bound to the node's data.

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.

GetBodyBackgroundBrush(ThemeResources)

Gets the body background brush from theme, with optional override.

protected virtual IBrush GetBodyBackgroundBrush(ThemeResources theme)

Parameters

theme ThemeResources

Returns

IBrush

GetDefaultLabel()

Gets the default label to display when the node has no label set.

protected virtual string GetDefaultLabel()

Returns

string

GetHeaderBackgroundBrush(ThemeResources)

Gets the header background brush from theme, with optional override.

protected virtual IBrush GetHeaderBackgroundBrush(ThemeResources theme)

Parameters

theme ThemeResources

Returns

IBrush

GetHeaderTextBrush(ThemeResources)

Gets the header text brush from theme, with optional override.

protected virtual IBrush GetHeaderTextBrush(ThemeResources theme)

Parameters

theme ThemeResources

Returns

IBrush

GetNodeBorderBrush(ThemeResources)

Gets the node border brush from theme, with optional override.

protected virtual IBrush GetNodeBorderBrush(ThemeResources theme)

Parameters

theme ThemeResources

Returns

IBrush

GetShadowColor(ThemeResources)

Gets the shadow color from theme, with optional override.

protected virtual Color GetShadowColor(ThemeResources theme)

Parameters

theme ThemeResources

Returns

Color

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.

UpdateSize(Control, Node, NodeRenderContext, double, double)

Updates the size of an existing node visual.

public override void UpdateSize(Control visual, Node node, NodeRenderContext context, double width, double height)

Parameters

visual Control

The node's visual control.

node Node

The node data.

context NodeRenderContext

The rendering context.

width double

The new width in canvas units.

height double

The new height in canvas units.

Remarks

IMPORTANT: Implementations MUST update ALL child elements within the visual, not just the root container. Failing to update child elements will cause the visual to appear unchanged during resize operations until a full re-render occurs.

For composite visuals (e.g., a Grid containing Rectangles, Borders, or Canvases), iterate through children and update their Width/Height properties accordingly.

public void UpdateSize(Control visual, Node node, NodeRenderContext context, double width, double height)
{
    var scaledWidth = width * context.Scale;
    var scaledHeight = height * context.Scale;

    if (visual is Grid grid)
    {
        grid.Width = scaledWidth;
        grid.Height = scaledHeight;

        // CRITICAL: Also update all child elements
        foreach (var child in grid.Children)
        {
            if (child is Rectangle rect)
            {
                rect.Width = scaledWidth;
                rect.Height = scaledHeight;
            }
        }
    }
}