Table of Contents

Class FlowCanvas

Namespace
FlowGraph.Avalonia
Assembly
FlowGraph.Avalonia.dll

FlowCanvas partial - Animation API and helpers.

public class FlowCanvas : UserControl, INotifyPropertyChanged, IDataContextProvider, ILogical, IThemeVariantHost, IResourceHost, IResourceNode, IStyleHost, ISetLogicalParent, ISetInheritanceParent, ISupportInitialize, IStyleable, INamed, IInputElement, IDataTemplateHost, ISetterValue, IFlowCanvasContext, IGraphContext
Inheritance
AvaloniaObject
Animatable
StyledElement
Visual
Layoutable
Interactive
InputElement
Control
TemplatedControl
ContentControl
UserControl
FlowCanvas
Implements
IDataContextProvider
ILogical
IThemeVariantHost
IResourceHost
IResourceNode
IStyleHost
ISetLogicalParent
ISetInheritanceParent
IStyleable
INamed
IInputElement
IDataTemplateHost
ISetterValue
Inherited Members
UserControl.OnCreateAutomationPeer()
ContentControl.ContentProperty
ContentControl.ContentTemplateProperty
ContentControl.HorizontalContentAlignmentProperty
ContentControl.VerticalContentAlignmentProperty
ContentControl.RegisterContentPresenter(ContentPresenter)
ContentControl.Content
ContentControl.ContentTemplate
ContentControl.Presenter
ContentControl.HorizontalContentAlignment
ContentControl.VerticalContentAlignment
TemplatedControl.BackgroundProperty
TemplatedControl.BackgroundSizingProperty
TemplatedControl.BorderBrushProperty
TemplatedControl.BorderThicknessProperty
TemplatedControl.CornerRadiusProperty
TemplatedControl.FontFamilyProperty
TemplatedControl.FontFeaturesProperty
TemplatedControl.FontSizeProperty
TemplatedControl.FontStyleProperty
TemplatedControl.FontWeightProperty
TemplatedControl.FontStretchProperty
TemplatedControl.ForegroundProperty
TemplatedControl.PaddingProperty
TemplatedControl.TemplateProperty
TemplatedControl.IsTemplateFocusTargetProperty
TemplatedControl.TemplateAppliedEvent
TemplatedControl.GetIsTemplateFocusTarget(Control)
TemplatedControl.ApplyTemplate()
TemplatedControl.GetTemplateFocusTarget()
TemplatedControl.OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs)
TemplatedControl.OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs)
TemplatedControl.OnApplyTemplate(TemplateAppliedEventArgs)
TemplatedControl.OnTemplateChanged(AvaloniaPropertyChangedEventArgs)
TemplatedControl.Background
TemplatedControl.BackgroundSizing
TemplatedControl.BorderBrush
TemplatedControl.BorderThickness
TemplatedControl.CornerRadius
TemplatedControl.FontFamily
TemplatedControl.FontFeatures
TemplatedControl.FontSize
TemplatedControl.FontStyle
TemplatedControl.FontWeight
TemplatedControl.FontStretch
TemplatedControl.Foreground
TemplatedControl.Padding
TemplatedControl.Template
TemplatedControl.TemplateApplied
Control.FocusAdornerProperty
Control.TagProperty
Control.ContextMenuProperty
Control.ContextFlyoutProperty
Control.RequestBringIntoViewEvent
Control.ContextRequestedEvent
Control.LoadedEvent
Control.UnloadedEvent
Control.SizeChangedEvent
Control.OnLoaded(RoutedEventArgs)
Control.OnUnloaded(RoutedEventArgs)
Control.OnAttachedToVisualTreeCore(VisualTreeAttachmentEventArgs)
Control.OnDetachedFromVisualTreeCore(VisualTreeAttachmentEventArgs)
Control.OnGotFocus(GotFocusEventArgs)
Control.OnLostFocus(RoutedEventArgs)
Control.OnPointerReleased(PointerReleasedEventArgs)
Control.OnKeyUp(KeyEventArgs)
Control.FocusAdorner
Control.DataTemplates
Control.ContextMenu
Control.ContextFlyout
Control.IsLoaded
Control.Tag
Control.ContextRequested
Control.Loaded
Control.Unloaded
Control.SizeChanged
InputElement.FocusableProperty
InputElement.IsEnabledProperty
InputElement.IsEffectivelyEnabledProperty
InputElement.CursorProperty
InputElement.IsKeyboardFocusWithinProperty
InputElement.IsFocusedProperty
InputElement.IsHitTestVisibleProperty
InputElement.IsPointerOverProperty
InputElement.IsTabStopProperty
InputElement.GotFocusEvent
InputElement.LostFocusEvent
InputElement.KeyDownEvent
InputElement.KeyUpEvent
InputElement.TabIndexProperty
InputElement.TextInputEvent
InputElement.TextInputMethodClientRequestedEvent
InputElement.PointerEnteredEvent
InputElement.PointerExitedEvent
InputElement.PointerMovedEvent
InputElement.PointerPressedEvent
InputElement.PointerReleasedEvent
InputElement.PointerCaptureLostEvent
InputElement.PointerWheelChangedEvent
InputElement.TappedEvent
InputElement.HoldingEvent
InputElement.DoubleTappedEvent
InputElement.Focus(NavigationMethod, KeyModifiers)
InputElement.OnAccessKey(RoutedEventArgs)
InputElement.OnTextInput(TextInputEventArgs)
InputElement.OnPointerEntered(PointerEventArgs)
InputElement.OnPointerExited(PointerEventArgs)
InputElement.OnPointerMoved(PointerEventArgs)
InputElement.OnPointerPressed(PointerPressedEventArgs)
InputElement.OnPointerCaptureLost(PointerCaptureLostEventArgs)
InputElement.OnPointerWheelChanged(PointerWheelEventArgs)
InputElement.UpdateIsEffectivelyEnabled()
InputElement.Focusable
InputElement.IsEnabled
InputElement.Cursor
InputElement.IsKeyboardFocusWithin
InputElement.IsFocused
InputElement.IsHitTestVisible
InputElement.IsPointerOver
InputElement.IsTabStop
InputElement.IsEffectivelyEnabled
InputElement.TabIndex
InputElement.KeyBindings
InputElement.IsEnabledCore
InputElement.GestureRecognizers
InputElement.GotFocus
InputElement.LostFocus
InputElement.KeyDown
InputElement.KeyUp
InputElement.TextInput
InputElement.TextInputMethodClientRequested
InputElement.PointerEntered
InputElement.PointerExited
InputElement.PointerMoved
InputElement.PointerPressed
InputElement.PointerReleased
InputElement.PointerCaptureLost
InputElement.PointerWheelChanged
InputElement.Tapped
InputElement.Holding
InputElement.DoubleTapped
Interactive.RaiseEvent(RoutedEventArgs)
Interactive.BuildEventRoute(RoutedEvent)
Layoutable.DesiredSizeProperty
Layoutable.WidthProperty
Layoutable.HeightProperty
Layoutable.MinWidthProperty
Layoutable.MaxWidthProperty
Layoutable.MinHeightProperty
Layoutable.MaxHeightProperty
Layoutable.MarginProperty
Layoutable.HorizontalAlignmentProperty
Layoutable.VerticalAlignmentProperty
Layoutable.UseLayoutRoundingProperty
Layoutable.UpdateLayout()
Layoutable.Measure(Size)
Layoutable.Arrange(Rect)
Layoutable.InvalidateMeasure()
Layoutable.InvalidateArrange()
Layoutable.AffectsMeasure<T>(params AvaloniaProperty[])
Layoutable.AffectsArrange<T>(params AvaloniaProperty[])
Layoutable.MeasureCore(Size)
Layoutable.MeasureOverride(Size)
Layoutable.ArrangeCore(Rect)
Layoutable.ArrangeOverride(Size)
Layoutable.OnMeasureInvalidated()
Layoutable.OnVisualParentChanged(Visual, Visual)
Layoutable.Width
Layoutable.Height
Layoutable.MinWidth
Layoutable.MaxWidth
Layoutable.MinHeight
Layoutable.MaxHeight
Layoutable.Margin
Layoutable.HorizontalAlignment
Layoutable.VerticalAlignment
Layoutable.DesiredSize
Layoutable.IsMeasureValid
Layoutable.IsArrangeValid
Layoutable.UseLayoutRounding
Layoutable.EffectiveViewportChanged
Layoutable.LayoutUpdated
Visual.BoundsProperty
Visual.ClipToBoundsProperty
Visual.ClipProperty
Visual.IsVisibleProperty
Visual.OpacityProperty
Visual.OpacityMaskProperty
Visual.EffectProperty
Visual.HasMirrorTransformProperty
Visual.RenderTransformProperty
Visual.RenderTransformOriginProperty
Visual.FlowDirectionProperty
Visual.VisualParentProperty
Visual.ZIndexProperty
Visual.GetFlowDirection(Visual)
Visual.SetFlowDirection(Visual, FlowDirection)
Visual.InvalidateVisual()
Visual.Render(DrawingContext)
Visual.AffectsRender<T>(params AvaloniaProperty[])
Visual.OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs)
Visual.InvalidateMirrorTransform()
Visual.Bounds
Visual.ClipToBounds
Visual.Clip
Visual.IsEffectivelyVisible
Visual.IsVisible
Visual.Opacity
Visual.OpacityMask
Visual.Effect
Visual.HasMirrorTransform
Visual.RenderTransform
Visual.RenderTransformOrigin
Visual.FlowDirection
Visual.ZIndex
Visual.VisualChildren
Visual.VisualRoot
Visual.BypassFlowDirectionPolicies
Visual.AttachedToVisualTree
Visual.DetachedFromVisualTree
StyledElement.DataContextProperty
StyledElement.NameProperty
StyledElement.ParentProperty
StyledElement.TemplatedParentProperty
StyledElement.ThemeProperty
StyledElement.BeginInit()
StyledElement.EndInit()
StyledElement.ApplyStyling()
StyledElement.InitializeIfNeeded()
StyledElement.OnDataContextBeginUpdate()
StyledElement.OnDataContextEndUpdate()
StyledElement.OnInitialized()
StyledElement.Name
StyledElement.Classes
StyledElement.DataContext
StyledElement.IsInitialized
StyledElement.Styles
StyledElement.StyleKey
StyledElement.Resources
StyledElement.TemplatedParent
StyledElement.Theme
StyledElement.LogicalChildren
StyledElement.PseudoClasses
StyledElement.StyleKeyOverride
StyledElement.Parent
StyledElement.ActualThemeVariant
StyledElement.AttachedToLogicalTree
StyledElement.DetachedFromLogicalTree
StyledElement.DataContextChanged
StyledElement.Initialized
StyledElement.ResourcesChanged
StyledElement.ActualThemeVariantChanged
Animatable.TransitionsProperty
Animatable.OnPropertyChangedCore(AvaloniaPropertyChangedEventArgs)
Animatable.Transitions
AvaloniaObject.CheckAccess()
AvaloniaObject.VerifyAccess()
AvaloniaObject.ClearValue(AvaloniaProperty)
AvaloniaObject.ClearValue<T>(AvaloniaProperty<T>)
AvaloniaObject.ClearValue<T>(StyledProperty<T>)
AvaloniaObject.ClearValue<T>(DirectPropertyBase<T>)
AvaloniaObject.GetHashCode()
AvaloniaObject.GetValue(AvaloniaProperty)
AvaloniaObject.GetValue<T>(StyledProperty<T>)
AvaloniaObject.GetValue<T>(DirectPropertyBase<T>)
AvaloniaObject.GetBaseValue<T>(StyledProperty<T>)
AvaloniaObject.IsAnimating(AvaloniaProperty)
AvaloniaObject.IsSet(AvaloniaProperty)
AvaloniaObject.SetValue<T>(StyledProperty<T>, T, BindingPriority)
AvaloniaObject.SetValue<T>(DirectPropertyBase<T>, T)
AvaloniaObject.SetCurrentValue<T>(StyledProperty<T>, T)
AvaloniaObject.Bind(AvaloniaProperty, IBinding)
AvaloniaObject.CoerceValue(AvaloniaProperty)
AvaloniaObject.RaisePropertyChanged<T>(DirectPropertyBase<T>, T, T)
AvaloniaObject.SetAndRaise<T>(DirectPropertyBase<T>, ref T, T)
AvaloniaObject.InheritanceParent
AvaloniaObject.this[AvaloniaProperty]
AvaloniaObject.this[IndexerDescriptor]
AvaloniaObject.PropertyChanged

Constructors

FlowCanvas()

public FlowCanvas()

Fields

GraphProperty

public static readonly StyledProperty<Graph?> GraphProperty

Field Value

StyledProperty<Graph>

SettingsProperty

public static readonly StyledProperty<FlowCanvasSettings> SettingsProperty

Field Value

StyledProperty<FlowCanvasSettings>

Properties

ActiveEffectsCount

Gets the total number of active edge effects (rainbow + pulse).

public int ActiveEffectsCount { get; }

Property Value

int

ActiveFlowAnimationCount

Gets the number of edges currently with active flow animations.

public int ActiveFlowAnimationCount { get; }

Property Value

int

Animations

Gets the animation manager for controlling animations.

public AnimationManager Animations { get; }

Property Value

AnimationManager

BackgroundRenderers

Gets the background renderer registry for custom background rendering.

public BackgroundRendererRegistry BackgroundRenderers { get; }

Property Value

BackgroundRendererRegistry

CollisionProvider

Gets or sets the collision provider for preventing node overlap during drag. Applied after SnapProvider, allowing collision to override snap when needed.

public ICollisionProvider? CollisionProvider { get; set; }

Property Value

ICollisionProvider

CommandHistory

Gets the command history for undo/redo operations.

public CommandHistory CommandHistory { get; }

Property Value

CommandHistory

ConnectionValidator

Gets or sets the connection validator for validating new connections.

public IConnectionValidator? ConnectionValidator { get; set; }

Property Value

IConnectionValidator

ContextMenuManager

Gets the context menu manager for customizing context menus.

public FlowCanvasContextMenu ContextMenuManager { get; }

Property Value

FlowCanvasContextMenu

CurrentInputState

Gets the current input state name (for debugging).

public string CurrentInputState { get; }

Property Value

string

CurrentZoom

Gets the current zoom level.

public double CurrentZoom { get; }

Property Value

double

DataFlow

Gets the graph executor for data flow processing. Returns null if data flow has not been enabled.

public GraphExecutor? DataFlow { get; }

Property Value

GraphExecutor

DebugRenderingPerformance

Gets or sets whether to output rendering performance diagnostics.

public bool DebugRenderingPerformance { get; set; }

Property Value

bool

EdgeEffects

Gets the edge effects manager for rainbow and pulse effects.

public EdgeEffectsManager EdgeEffects { get; }

Property Value

EdgeEffectsManager

Remarks

The EdgeEffectsManager automatically handles:

EdgeFlowAnimations

Gets the edge flow animation manager for automatic style-based animations.

public EdgeFlowAnimationManager EdgeFlowAnimations { get; }

Property Value

EdgeFlowAnimationManager

Remarks

The EdgeFlowAnimationManager automatically starts/stops flow animations based on AnimatedFlow settings. Edges with AnimatedFlow=true in their style will automatically animate.

EdgeRenderers

Gets the edge renderer registry for registering custom edge types.

public EdgeRendererRegistry EdgeRenderers { get; }

Property Value

EdgeRendererRegistry

Graph

The graph to display and edit.

public Graph? Graph { get; set; }

Property Value

Graph

Groups

Gets the group manager for advanced group operations.

public GroupManager Groups { get; }

Property Value

GroupManager

IsDataFlowEnabled

Gets whether data flow is enabled for this canvas.

public bool IsDataFlowEnabled { get; }

Property Value

bool

IsDirectRenderingEnabled

Gets whether direct rendering mode is enabled.

public bool IsDirectRenderingEnabled { get; }

Property Value

bool

LayoutTransitions

Gets the layout transition manager for animating layout/arrange operations.

public LayoutTransitionManager LayoutTransitions { get; }

Property Value

LayoutTransitionManager

NodeRenderers

Gets the node renderer registry for registering custom node types.

public NodeRendererRegistry NodeRenderers { get; }

Property Value

NodeRendererRegistry

Offset

Gets the current pan offset in canvas coordinates.

public Point Offset { get; }

Property Value

Point

PortRenderers

Gets the port renderer registry for registering custom port types.

public PortRendererRegistry PortRenderers { get; }

Property Value

PortRendererRegistry

RenderService

Gets the unified render service for programmatic rendering operations. This service abstracts the difference between retained and direct rendering modes, ensuring all operations work correctly regardless of which mode is active.

public ICanvasRenderService RenderService { get; }

Property Value

ICanvasRenderService

Routing

Gets the edge routing manager for controlling edge routing.

public EdgeRoutingManager Routing { get; }

Property Value

EdgeRoutingManager

Selection

Gets the selection manager for managing node and edge selection.

public SelectionManager Selection { get; }

Property Value

SelectionManager

Settings

Settings for the canvas appearance and behavior.

public FlowCanvasSettings Settings { get; set; }

Property Value

FlowCanvasSettings

ShapeRenderers

Gets the shape renderer registry for registering custom shape types.

public ShapeRendererRegistry ShapeRenderers { get; }

Property Value

ShapeRendererRegistry

SnapProvider

Gets or sets the snap provider for providing snap offsets during drag operations. External systems (like helper lines, guides) can register as a snap provider to influence node positions during drag without directly setting positions.

public ISnapProvider? SnapProvider { get; set; }

Property Value

ISnapProvider

Viewport

Gets the viewport state for external components (e.g., minimap).

public ViewportState Viewport { get; }

Property Value

ViewportState

VisibleBounds

Gets the visible bounds in canvas coordinates. This represents the area of the canvas currently visible in the viewport.

public Rect VisibleBounds { get; }

Property Value

Rect

Methods

AddNodesToGroup(string, IEnumerable<string>)

Adds nodes to an existing group.

public void AddNodesToGroup(string groupId, IEnumerable<string> nodeIds)

Parameters

groupId string

The ID of the target group.

nodeIds IEnumerable<string>

The IDs of the nodes to add.

AddSelectedToGroup(string)

Adds selected nodes to the specified group.

public void AddSelectedToGroup(string groupId)

Parameters

groupId string

The ID of the target group.

AnimateEdgeColor(Edge, Color, double, Action?)

Animates an edge's color.

public void AnimateEdgeColor(Edge edge, Color targetColor, double duration = 0.3, Action? onComplete = null)

Parameters

edge Edge

The edge to animate.

targetColor Color

Target color.

duration double

Animation duration in seconds (default: 0.3).

onComplete Action

Optional callback when animation completes.

AnimateEdgeFadeIn(Edge, double, Action?)

Animates an edge with a fade-in effect.

public void AnimateEdgeFadeIn(Edge edge, double duration = 0.3, Action? onComplete = null)

Parameters

edge Edge

The edge to animate.

duration double

Animation duration in seconds (default: 0.3).

onComplete Action

Optional callback when animation completes.

AnimateEdgeFadeOut(Edge, double, Action?)

Animates an edge with a fade-out effect.

public void AnimateEdgeFadeOut(Edge edge, double duration = 0.3, Action? onComplete = null)

Parameters

edge Edge

The edge to animate.

duration double

Animation duration in seconds (default: 0.3).

onComplete Action

Optional callback when animation completes.

AnimateEdgePulse(Edge, int, Action?)

Animates an edge with a pulse/highlight effect.

public void AnimateEdgePulse(Edge edge, int pulseCount = 2, Action? onComplete = null)

Parameters

edge Edge

The edge to animate.

pulseCount int

Number of pulse cycles (default: 2).

onComplete Action

Optional callback when animation completes.

AnimateGroupCollapse(string, double, Action?)

Animates a group collapsing with sequenced transitions:

  1. Children nodes and edges fade out together
  2. Group shrinks
public void AnimateGroupCollapse(string groupId, double duration = 0.5, Action? onComplete = null)

Parameters

groupId string

The ID of the group to collapse.

duration double

Total animation duration in seconds (default: 0.5).

onComplete Action

Optional callback when animation completes.

AnimateGroupExpand(string, double, Action?)

Animates a group expanding with sequenced transitions:

  1. Group grows
  2. Children nodes and edges fade in together
public void AnimateGroupExpand(string groupId, double duration = 0.5, Action? onComplete = null)

Parameters

groupId string

The ID of the group to expand.

duration double

Total animation duration in seconds (default: 0.5).

onComplete Action

Optional callback when animation completes.

AnimateNodeAppear(Node, double, Action?)

Smoothly animates a node appearing with fade and scale effect.

public void AnimateNodeAppear(Node node, double duration = 0.3, Action? onComplete = null)

Parameters

node Node

The node to animate.

duration double

Animation duration in seconds (default: 0.3).

onComplete Action

Optional callback when animation completes.

AnimateNodeDisappear(Node, double, Action?)

Animates a node disappearing with fade and scale effect.

public void AnimateNodeDisappear(Node node, double duration = 0.2, Action? onComplete = null)

Parameters

node Node

The node to animate.

duration double

Animation duration in seconds (default: 0.2).

onComplete Action

Optional callback when animation completes.

AnimateNodeTo(Node, Point, double, Func<double, double>?)

Smoothly animates a node to a new position.

public void AnimateNodeTo(Node node, Point targetPosition, double duration = 0.3, Func<double, double>? easing = null)

Parameters

node Node

The node to animate.

targetPosition Point

Target position in canvas coordinates.

duration double

Animation duration in seconds (default: 0.3).

easing Func<double, double>

Optional easing function.

AnimateNodesAppear(IEnumerable<Node>, double, double, Action?)

Animates multiple nodes appearing with staggered effect.

public void AnimateNodesAppear(IEnumerable<Node> nodes, double duration = 0.3, double stagger = 0.05, Action? onComplete = null)

Parameters

nodes IEnumerable<Node>

The nodes to animate.

duration double

Animation duration per node in seconds (default: 0.3).

stagger double

Delay between each node's animation start (default: 0.05).

onComplete Action

Optional callback when all animations complete.

AnimateNodesDisappear(IEnumerable<Node>, double, double, Action?)

Animates multiple nodes disappearing with staggered effect.

public void AnimateNodesDisappear(IEnumerable<Node> nodes, double duration = 0.2, double stagger = 0.03, Action? onComplete = null)

Parameters

nodes IEnumerable<Node>

The nodes to animate.

duration double

Animation duration per node in seconds (default: 0.2).

stagger double

Delay between each node's animation start (default: 0.03).

onComplete Action

Optional callback when all animations complete.

AnimateNodesTo(IReadOnlyDictionary<Node, Point>, double, Func<double, double>?)

Smoothly animates multiple nodes to new positions.

public void AnimateNodesTo(IReadOnlyDictionary<Node, Point> nodePositions, double duration = 0.3, Func<double, double>? easing = null)

Parameters

nodePositions IReadOnlyDictionary<Node, Point>

Dictionary mapping nodes to their target positions.

duration double

Animation duration in seconds (default: 0.3).

easing Func<double, double>

Optional easing function.

AnimateSelectionPulse(Node, Action?)

Animates a brief selection pulse on a node.

public void AnimateSelectionPulse(Node node, Action? onComplete = null)

Parameters

node Node

The node to pulse.

onComplete Action

Optional callback when animation completes.

AutoResizeAllGroups()

Auto-resizes all groups to fit their children.

public void AutoResizeAllGroups()

AutoResizeGroup(string)

Auto-resizes a group to fit its children.

public void AutoResizeGroup(string groupId)

Parameters

groupId string

The ID of the group to resize.

BeginDataFlowBatch()

Begins a batch update for data flow. Changes won't propagate until EndDataFlowBatch is called.

public void BeginDataFlowBatch()

BeginEditEdgeLabel(Edge)

Begins inline editing for an edge's label. Shows an inline TextBox over the edge label.

public bool BeginEditEdgeLabel(Edge edge)

Parameters

edge Edge

The edge to edit.

Returns

bool

True if editing started successfully.

BeginEditNodeLabel(Node)

Begins inline editing for a node's label. In visual tree mode, uses the node's renderer to show an inline TextBox. In direct rendering mode, creates a TextBox overlay at the node's position.

public bool BeginEditNodeLabel(Node node)

Parameters

node Node

The node to edit.

Returns

bool

True if editing started successfully.

BeginEditShapeText(ShapeElement)

Begins inline editing for a shape's text (e.g., sticky notes). Shows an inline TextBox overlay on the shape.

public bool BeginEditShapeText(ShapeElement shape)

Parameters

shape ShapeElement

The shape to edit.

Returns

bool

True if editing started successfully.

CanvasToScreen(Point)

Converts canvas coordinates to screen coordinates.

public Point CanvasToScreen(Point canvasPoint)

Parameters

canvasPoint Point

Position in canvas coordinates.

Returns

Point

The equivalent position in screen coordinates.

CanvasToScreen(double, double)

Converts canvas coordinates to screen coordinates.

public Point CanvasToScreen(double canvasX, double canvasY)

Parameters

canvasX double

X position in canvas coordinates.

canvasY double

Y position in canvas coordinates.

Returns

Point

The equivalent position in screen coordinates.

CenterOn(double, double)

Centers the viewport on a specific point in canvas coordinates.

public void CenterOn(double x, double y)

Parameters

x double
y double

CenterOnAnimated(double, double, double, Func<double, double>?)

Smoothly animates to center on a specific point.

public void CenterOnAnimated(double x, double y, double duration = 0.3, Func<double, double>? easing = null)

Parameters

x double

X coordinate in canvas coordinates.

y double

Y coordinate in canvas coordinates.

duration double

Animation duration in seconds (default: 0.3).

easing Func<double, double>

Optional easing function.

CenterOnGraph()

Centers the viewport on the center of all elements (nodes and shapes) without changing zoom.

public void CenterOnGraph()

CenterOnGraphAnimated(double, Func<double, double>?)

Smoothly animates to center on the graph.

public void CenterOnGraphAnimated(double duration = 0.3, Func<double, double>? easing = null)

Parameters

duration double

Animation duration in seconds (default: 0.3).

easing Func<double, double>

Optional easing function.

CenterOnNodeAnimated(Node, double, Func<double, double>?)

Smoothly animates to center on a specific node.

public void CenterOnNodeAnimated(Node node, double duration = 0.3, Func<double, double>? easing = null)

Parameters

node Node

The node to center on.

duration double

Animation duration in seconds (default: 0.3).

easing Func<double, double>

Optional easing function.

CollapseAllGroups()

Collapses all groups in the graph.

public void CollapseAllGroups()

Copy()

Copies selected nodes to the clipboard.

public void Copy()

CreateInputProcessor<T>(Node, string, T?)

Creates and registers an input processor for a node.

public InputNodeProcessor<T> CreateInputProcessor<T>(Node node, string outputPortId = "out", T? initialValue = default)

Parameters

node Node

The node.

outputPortId string

The output port ID.

initialValue T

The initial value.

Returns

InputNodeProcessor<T>

The created processor.

Type Parameters

T

The value type.

CreateOutputProcessor<T>(Node, string)

Creates and registers an output processor for a node.

public OutputNodeProcessor<T> CreateOutputProcessor<T>(Node node, string inputPortId = "in")

Parameters

node Node

The node.

inputPortId string

The input port ID.

Returns

OutputNodeProcessor<T>

The created processor.

Type Parameters

T

The value type.

Cut()

Cuts selected nodes to the clipboard.

public void Cut()

DisableDataFlow()

Disables data flow processing and disposes the executor.

public void DisableDataFlow()

DisableDirectRendering()

Disables direct rendering mode and returns to normal visual tree rendering.

public void DisableDirectRendering()

DisableSimplifiedRendering()

Disables simplified rendering and restores the default node renderers.

public void DisableSimplifiedRendering()

Duplicate()

Duplicates selected nodes in place.

public void Duplicate()

EnableDataFlow()

Enables data flow processing for this canvas. Creates a GraphExecutor that will handle value propagation between connected nodes.

public GraphExecutor EnableDataFlow()

Returns

GraphExecutor

The created GraphExecutor.

EnableDirectRendering()

Enables direct GPU-accelerated rendering mode for maximum performance with very large graphs. This bypasses the Avalonia visual tree entirely and draws directly to a DrawingContext. Supports custom node renderers via IDirectNodeRenderer interface.

public void EnableDirectRendering()

EnableSimplifiedRendering()

Enables simplified node rendering for better performance with large graphs. This replaces the default renderer with a minimal renderer that uses fewer visual elements. Call before loading a large graph.

public void EnableSimplifiedRendering()

EndDataFlowBatch()

Ends a batch update and executes all affected nodes.

public void EndDataFlowBatch()

EndEditNodeLabel(Node)

Ends inline editing for a node's label and commits the change.

public void EndEditNodeLabel(Node node)

Parameters

node Node

The node being edited.

ExecuteFromNode(string)

Executes only nodes affected by a change to the specified node.

public void ExecuteFromNode(string nodeId)

Parameters

nodeId string

The node that changed.

ExecuteGraph()

Executes the entire graph in topological order.

public void ExecuteGraph()

ExpandAllGroups()

Expands all groups in the graph.

public void ExpandAllGroups()

FitToView()

Fits all elements (nodes and shapes) into the viewport.

public void FitToView()

FitToViewAnimated(double, Func<double, double>?)

Smoothly animates to fit all nodes into the viewport.

public void FitToViewAnimated(double duration = 0.3, Func<double, double>? easing = null)

Parameters

duration double

Animation duration in seconds (default: 0.3).

easing Func<double, double>

Optional easing function.

GetAllGroups()

Gets all groups in the graph.

public IEnumerable<Node> GetAllGroups()

Returns

IEnumerable<Node>

GetCanvasPosition(PointerEventArgs)

Gets canvas coordinates from a pointer event. This is the correct way to get coordinates for hit testing, node positioning, etc.

[Obsolete("Use GetTypedCanvasPosition(e) instead, which returns a type-safe CanvasPoint.")]
public Point GetCanvasPosition(PointerEventArgs e)

Parameters

e PointerEventArgs

The pointer event.

Returns

Point

Position in canvas coordinates.

Examples

// In your Pro extension service:
var canvasPos = _canvas.GetCanvasPosition(e);
var hitHandle = HitTest(canvasPos.X, canvasPos.Y);

Remarks

This method uses e.GetPosition(MainCanvas) internally, which correctly

accounts for the viewport transform. Prefer this over ScreenToCanvas(double, double).

DEPRECATED: For new code, use GetTypedCanvasPosition(PointerEventArgs) which returns a type-safe CanvasPoint instead.

GetGroupAtPoint(Point)

Gets the group at a specific canvas point.

public string? GetGroupAtPoint(Point canvasPoint)

Parameters

canvasPoint Point

The point in canvas coordinates.

Returns

string

The group ID, or null if no group at that point.

GetGroupChildren(string)

Gets the children of a specific group.

public IEnumerable<Node> GetGroupChildren(string groupId)

Parameters

groupId string

The ID of the group.

Returns

IEnumerable<Node>

GetNodeVisual(string)

Gets the visual control for a node by its ID. This can be used to access the node's rendered visual for customization (e.g., changing border color).

public Control? GetNodeVisual(string nodeId)

Parameters

nodeId string

The node ID.

Returns

Control

The node's visual control, or null if not found.

GetProcessor(string)

Gets a processor by node ID.

public INodeProcessor? GetProcessor(string nodeId)

Parameters

nodeId string

The node ID.

Returns

INodeProcessor

The processor, or null if not found.

GetProcessor<T>(string)

Gets a typed processor by node ID.

public T? GetProcessor<T>(string nodeId) where T : class, INodeProcessor

Parameters

nodeId string

The node ID.

Returns

T

The processor, or null if not found or wrong type.

Type Parameters

T

The processor type.

GetShapeVisual(string)

Gets the visual control for a shape element by its ID.

public Control? GetShapeVisual(string shapeId)

Parameters

shapeId string

The shape ID.

Returns

Control

The shape's visual control, or null if not found.

GetTypedCanvasPosition(PointerEventArgs)

Gets canvas coordinates from a pointer event using the type-safe coordinate system. This is the preferred method for extension/Pro code to get canvas coordinates.

public CanvasPoint GetTypedCanvasPosition(PointerEventArgs e)

Parameters

e PointerEventArgs

The pointer event.

Returns

CanvasPoint

Position in canvas coordinates as a type-safe CanvasPoint.

Remarks

Use canvas coordinates for:

  • Hit testing on the canvas
  • Node/edge positions
  • Selection box bounds
  • Any position that needs to be stored or compared with node data

This method uses the same coordinate system as the internal input states, ensuring consistent behavior in both Visual Tree and Direct Rendering modes.

GetTypedViewportPosition(PointerEventArgs)

Gets viewport coordinates from a pointer event using the type-safe coordinate system. This is the preferred method for extension/Pro code to get viewport coordinates.

public ViewportPoint GetTypedViewportPosition(PointerEventArgs e)

Parameters

e PointerEventArgs

The pointer event.

Returns

ViewportPoint

Position in viewport coordinates as a type-safe ViewportPoint.

Remarks

Use viewport coordinates for:

  • Pan calculations (delta from last position)
  • Auto-pan edge detection
  • UI overlay positioning
  • Any position relative to the visible screen area

GetViewportPosition(PointerEventArgs)

Gets viewport/screen coordinates from a pointer event. Use this for pan calculations, auto-pan edge detection, etc.

[Obsolete("Use GetTypedViewportPosition(e) instead, which returns a type-safe ViewportPoint.")]
public Point GetViewportPosition(PointerEventArgs e)

Parameters

e PointerEventArgs

The pointer event.

Returns

Point

Position in viewport/screen coordinates.

Remarks

DEPRECATED: For new code, use GetTypedViewportPosition(PointerEventArgs) which returns a type-safe ViewportPoint instead.

GetVisibleNodes()

Gets all visible nodes (excluding those hidden by collapsed groups).

public IEnumerable<Node> GetVisibleNodes()

Returns

IEnumerable<Node>

GroupSelected(string?)

Groups the selected nodes into a new group.

public Node? GroupSelected(string? groupLabel = null)

Parameters

groupLabel string

Optional label for the group.

Returns

Node

The created group node, or null if grouping failed.

InitializeComponent(bool)

Wires up the controls and optionally loads XAML markup and attaches dev tools (if Avalonia.Diagnostics package is referenced).

[ExcludeFromCodeCoverage]
public void InitializeComponent(bool loadXaml = true)

Parameters

loadXaml bool

Should the XAML be loaded into the component.

IsEditingNodeLabel(Node)

Gets whether a node is currently in edit mode.

public bool IsEditingNodeLabel(Node node)

Parameters

node Node

The node to check.

Returns

bool

True if the node is being edited.

IsNodeVisible(string)

Checks if a node is visible (not hidden by a collapsed parent group).

public bool IsNodeVisible(string nodeId)

Parameters

nodeId string

The ID of the node to check.

Returns

bool

OnAttachedToVisualTree(VisualTreeAttachmentEventArgs)

Called when the control is added to a rooted visual tree.

protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)

Parameters

e VisualTreeAttachmentEventArgs

The event args.

OnKeyDown(KeyEventArgs)

Invoked when an unhandled Avalonia.Input.InputElement.KeyDownEvent reaches an element in its route that is derived from this class. Implement this method to add class handling for this event.

protected override void OnKeyDown(KeyEventArgs e)

Parameters

e KeyEventArgs

Data about the event.

OnPropertyChanged(AvaloniaPropertyChangedEventArgs)

Called when a avalonia property changes on the object.

protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)

Parameters

change AvaloniaPropertyChangedEventArgs

The property change details.

OnSizeChanged(SizeChangedEventArgs)

Raises the Avalonia.Controls.Control.SizeChanged event.

protected override void OnSizeChanged(SizeChangedEventArgs e)

Parameters

e SizeChangedEventArgs

The event args.

Paste()

Pastes nodes from the clipboard.

public void Paste()

Redo()

Redoes the last undone command.

public void Redo()

Refresh()

Forces a complete re-render of the graph.

public void Refresh()

RefreshEdges()

Forces a re-render of all edges. Useful after modifying edge properties.

public void RefreshEdges()

RegisterProcessor(INodeProcessor)

Registers a processor for a node. If data flow is enabled, also registers with the executor.

public void RegisterProcessor(INodeProcessor processor)

Parameters

processor INodeProcessor

The processor to register.

RemoveNodesFromGroup(IEnumerable<string>)

Removes nodes from their parent group.

public void RemoveNodesFromGroup(IEnumerable<string> nodeIds)

Parameters

nodeIds IEnumerable<string>

The IDs of the nodes to remove from their groups.

RemoveSelectedFromGroups()

Removes selected nodes from their parent groups.

public void RemoveSelectedFromGroups()

ResetZoom()

Resets zoom to 100%, keeping the viewport center fixed.

public void ResetZoom()

ScreenToCanvas(Point)

Converts viewport coordinates to canvas coordinates.

[Obsolete("For pointer events, use GetCanvasPosition(e) instead. This method is for viewport coordinate conversion only.")]
public Point ScreenToCanvas(Point screenPoint)

Parameters

screenPoint Point

Position in viewport coordinates.

Returns

Point

The equivalent position in canvas coordinates.

Remarks

WARNING: Do not use this with e.GetPosition(this) for pointer events!

For pointer events, use GetCanvasPosition(PointerEventArgs) instead.

ScreenToCanvas(double, double)

Converts viewport coordinates to canvas coordinates.

[Obsolete("For pointer events, use GetCanvasPosition(e) instead. This method is for viewport coordinate conversion only.")]
public Point ScreenToCanvas(double screenX, double screenY)

Parameters

screenX double

X position in viewport coordinates.

screenY double

Y position in viewport coordinates.

Returns

Point

The equivalent position in canvas coordinates.

Remarks

WARNING: Do not use this with e.GetPosition(this) for pointer events!

For pointer events, use GetCanvasPosition(PointerEventArgs) instead,

which correctly handles the MainCanvas transform.

This method is intended for converting known viewport coordinates (e.g., from bounds calculations).

SetGroupCollapsed(string, bool)

Sets the collapsed state of a group.

public void SetGroupCollapsed(string groupId, bool collapsed)

Parameters

groupId string

The ID of the group.

collapsed bool

True to collapse, false to expand.

SetZoom(double)

Sets the zoom level.

public void SetZoom(double zoom)

Parameters

zoom double

StartEdgeFlowAnimation(Edge, double, bool)

Starts a continuous flow animation on an edge (animated dashed line).

public EdgeFlowAnimation StartEdgeFlowAnimation(Edge edge, double speed = 50, bool reverse = false)

Parameters

edge Edge

The edge to animate.

speed double

Speed of the flow animation (default: 50).

reverse bool

If true, flow goes from target to source. If false (default), flow goes from source to target.

Returns

EdgeFlowAnimation

The animation instance (can be used to stop it later).

StopAllAnimations()

Stops all running animations.

public void StopAllAnimations()

StopEdgeFlowAnimation(EdgeFlowAnimation)

Stops an edge flow animation.

public void StopEdgeFlowAnimation(EdgeFlowAnimation animation)

Parameters

animation EdgeFlowAnimation

The animation to stop.

ToggleGroupCollapse(string)

Toggles the collapsed state of a group.

public void ToggleGroupCollapse(string groupId)

Parameters

groupId string

The ID of the group to toggle.

Undo()

Undoes the last command.

public void Undo()

UngroupSelected()

Ungroups the selected group(s).

public void UngroupSelected()

UnregisterProcessor(string)

Unregisters a processor for a node.

public bool UnregisterProcessor(string nodeId)

Parameters

nodeId string

The node ID.

Returns

bool

True if a processor was found and removed.

ZoomIn()

Zooms in by one step, keeping the viewport center fixed.

public void ZoomIn()

ZoomOut()

Zooms out by one step, keeping the viewport center fixed.

public void ZoomOut()

ZoomToAnimated(double, double, Func<double, double>?)

Smoothly animates to a specific zoom level.

public void ZoomToAnimated(double targetZoom, double duration = 0.2, Func<double, double>? easing = null)

Parameters

targetZoom double

Target zoom level.

duration double

Animation duration in seconds (default: 0.2).

easing Func<double, double>

Optional easing function.

Events

ConnectEnd

Event raised when connection creation ends.

public event EventHandler<ConnectEndEventArgs>? ConnectEnd

Event Type

EventHandler<ConnectEndEventArgs>

ConnectStart

Event raised when connection creation starts.

public event EventHandler<ConnectStartEventArgs>? ConnectStart

Event Type

EventHandler<ConnectStartEventArgs>

ConnectionCompleted

Event raised when a connection is successfully completed.

public event EventHandler<ConnectionCompletedEventArgs>? ConnectionCompleted

Event Type

EventHandler<ConnectionCompletedEventArgs>

ConnectionRejected

Event raised when a connection is rejected by the validator.

public event EventHandler<ConnectionRejectedEventArgs>? ConnectionRejected

Event Type

EventHandler<ConnectionRejectedEventArgs>

DebugOutput

Event raised when debug performance info is available. Subscribe to this to receive performance metrics.

public event Action<string>? DebugOutput

Event Type

Action<string>

EdgeClicked

Event raised when an edge is clicked.

public event EventHandler<EdgeClickedEventArgs>? EdgeClicked

Event Type

EventHandler<EdgeClickedEventArgs>

EdgeDisconnected

Event raised when an edge is disconnected.

public event EventHandler<EdgeDisconnectedEventArgs>? EdgeDisconnected

Event Type

EventHandler<EdgeDisconnectedEventArgs>

EdgeLabelEditRequested

Event raised when a user double-clicks an edge label to edit it.

public event EventHandler<EdgeLabelEditRequestedEventArgs>? EdgeLabelEditRequested

Event Type

EventHandler<EdgeLabelEditRequestedEventArgs>

EdgeReconnected

Event raised when an edge is reconnected to a different port.

public event EventHandler<EdgeReconnectedEventArgs>? EdgeReconnected

Event Type

EventHandler<EdgeReconnectedEventArgs>

GroupCollapsedChanged

Event raised when a group's collapsed state changes.

public event EventHandler<GroupCollapsedEventArgs>? GroupCollapsedChanged

Event Type

EventHandler<GroupCollapsedEventArgs>

InputStateChanged

Event raised when the input state changes.

public event EventHandler<StateChangedEventArgs>? InputStateChanged

Event Type

EventHandler<StateChangedEventArgs>

NodeDragStart

Event raised when node dragging starts.

public event EventHandler<NodeDragStartEventArgs>? NodeDragStart

Event Type

EventHandler<NodeDragStartEventArgs>

NodeDragStop

Event raised when node dragging stops.

public event EventHandler<NodeDragStopEventArgs>? NodeDragStop

Event Type

EventHandler<NodeDragStopEventArgs>

NodeLabelEditRequested

Event raised when a user double-clicks a node to edit its label.

public event EventHandler<NodeLabelEditRequestedEventArgs>? NodeLabelEditRequested

Event Type

EventHandler<NodeLabelEditRequestedEventArgs>

NodeResized

Event raised when a node is resized.

public event EventHandler<NodeResizedEventArgs>? NodeResized

Event Type

EventHandler<NodeResizedEventArgs>

NodeResizing

Event raised when a node is being resized (in progress).

public event EventHandler<NodeResizingEventArgs>? NodeResizing

Event Type

EventHandler<NodeResizingEventArgs>

NodesDragged

Event raised when nodes have been dragged to a new position.

public event EventHandler<NodesDraggedEventArgs>? NodesDragged

Event Type

EventHandler<NodesDraggedEventArgs>

SelectionChanged

Event raised when the selection changes.

public event EventHandler<SelectionChangedEventArgs>? SelectionChanged

Event Type

EventHandler<SelectionChangedEventArgs>

ShapeResized

Event raised when a shape resize is completed.

public event EventHandler<ShapeResizedEventArgs>? ShapeResized

Event Type

EventHandler<ShapeResizedEventArgs>

ShapeResizing

Event raised when a shape is being resized (in progress).

public event EventHandler<ShapeResizingEventArgs>? ShapeResizing

Event Type

EventHandler<ShapeResizingEventArgs>

ShapeTextEditRequested

Event raised when a user double-clicks a shape (e.g., sticky note) to edit its text.

public event EventHandler<ShapeTextEditRequestedEventArgs>? ShapeTextEditRequested

Event Type

EventHandler<ShapeTextEditRequestedEventArgs>

ViewportChanged

Event raised when the viewport changes (pan, zoom).

public event EventHandler<ViewportChangedEventArgs>? ViewportChanged

Event Type

EventHandler<ViewportChangedEventArgs>