Class FlowCanvas
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
-
AvaloniaObjectAnimatableStyledElementVisualLayoutableInteractiveInputElementControlTemplatedControlContentControlUserControlFlowCanvas
- Implements
-
IDataContextProviderILogicalIThemeVariantHostIResourceHostIResourceNodeIStyleHostISetLogicalParentISetInheritanceParentIStyleableINamedIInputElementIDataTemplateHostISetterValue
- Inherited Members
-
UserControl.OnCreateAutomationPeer()ContentControl.ContentPropertyContentControl.ContentTemplatePropertyContentControl.HorizontalContentAlignmentPropertyContentControl.VerticalContentAlignmentPropertyContentControl.RegisterContentPresenter(ContentPresenter)ContentControl.ContentContentControl.ContentTemplateContentControl.PresenterContentControl.HorizontalContentAlignmentContentControl.VerticalContentAlignmentTemplatedControl.BackgroundPropertyTemplatedControl.BackgroundSizingPropertyTemplatedControl.BorderBrushPropertyTemplatedControl.BorderThicknessPropertyTemplatedControl.CornerRadiusPropertyTemplatedControl.FontFamilyPropertyTemplatedControl.FontFeaturesPropertyTemplatedControl.FontSizePropertyTemplatedControl.FontStylePropertyTemplatedControl.FontWeightPropertyTemplatedControl.FontStretchPropertyTemplatedControl.ForegroundPropertyTemplatedControl.PaddingPropertyTemplatedControl.TemplatePropertyTemplatedControl.IsTemplateFocusTargetPropertyTemplatedControl.TemplateAppliedEventTemplatedControl.GetIsTemplateFocusTarget(Control)TemplatedControl.ApplyTemplate()TemplatedControl.GetTemplateFocusTarget()TemplatedControl.OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs)TemplatedControl.OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs)TemplatedControl.OnApplyTemplate(TemplateAppliedEventArgs)TemplatedControl.OnTemplateChanged(AvaloniaPropertyChangedEventArgs)TemplatedControl.BackgroundTemplatedControl.BackgroundSizingTemplatedControl.BorderBrushTemplatedControl.BorderThicknessTemplatedControl.CornerRadiusTemplatedControl.FontFamilyTemplatedControl.FontFeaturesTemplatedControl.FontSizeTemplatedControl.FontStyleTemplatedControl.FontWeightTemplatedControl.FontStretchTemplatedControl.ForegroundTemplatedControl.PaddingTemplatedControl.TemplateTemplatedControl.TemplateAppliedControl.FocusAdornerPropertyControl.TagPropertyControl.ContextMenuPropertyControl.ContextFlyoutPropertyControl.RequestBringIntoViewEventControl.ContextRequestedEventControl.LoadedEventControl.UnloadedEventControl.SizeChangedEventControl.OnLoaded(RoutedEventArgs)Control.OnUnloaded(RoutedEventArgs)Control.OnAttachedToVisualTreeCore(VisualTreeAttachmentEventArgs)Control.OnDetachedFromVisualTreeCore(VisualTreeAttachmentEventArgs)Control.OnGotFocus(GotFocusEventArgs)Control.OnLostFocus(RoutedEventArgs)Control.OnPointerReleased(PointerReleasedEventArgs)Control.OnKeyUp(KeyEventArgs)Control.FocusAdornerControl.DataTemplatesControl.ContextMenuControl.ContextFlyoutControl.IsLoadedControl.TagControl.ContextRequestedControl.LoadedControl.UnloadedControl.SizeChangedInputElement.FocusablePropertyInputElement.IsEnabledPropertyInputElement.IsEffectivelyEnabledPropertyInputElement.CursorPropertyInputElement.IsKeyboardFocusWithinPropertyInputElement.IsFocusedPropertyInputElement.IsHitTestVisiblePropertyInputElement.IsPointerOverPropertyInputElement.IsTabStopPropertyInputElement.GotFocusEventInputElement.LostFocusEventInputElement.KeyDownEventInputElement.KeyUpEventInputElement.TabIndexPropertyInputElement.TextInputEventInputElement.TextInputMethodClientRequestedEventInputElement.PointerEnteredEventInputElement.PointerExitedEventInputElement.PointerMovedEventInputElement.PointerPressedEventInputElement.PointerReleasedEventInputElement.PointerCaptureLostEventInputElement.PointerWheelChangedEventInputElement.TappedEventInputElement.HoldingEventInputElement.DoubleTappedEventInputElement.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.FocusableInputElement.IsEnabledInputElement.CursorInputElement.IsKeyboardFocusWithinInputElement.IsFocusedInputElement.IsHitTestVisibleInputElement.IsPointerOverInputElement.IsTabStopInputElement.IsEffectivelyEnabledInputElement.TabIndexInputElement.KeyBindingsInputElement.IsEnabledCoreInputElement.GestureRecognizersInputElement.GotFocusInputElement.LostFocusInputElement.KeyDownInputElement.KeyUpInputElement.TextInputInputElement.TextInputMethodClientRequestedInputElement.PointerEnteredInputElement.PointerExitedInputElement.PointerMovedInputElement.PointerPressedInputElement.PointerReleasedInputElement.PointerCaptureLostInputElement.PointerWheelChangedInputElement.TappedInputElement.HoldingInputElement.DoubleTappedInteractive.RaiseEvent(RoutedEventArgs)Interactive.BuildEventRoute(RoutedEvent)Layoutable.DesiredSizePropertyLayoutable.WidthPropertyLayoutable.HeightPropertyLayoutable.MinWidthPropertyLayoutable.MaxWidthPropertyLayoutable.MinHeightPropertyLayoutable.MaxHeightPropertyLayoutable.MarginPropertyLayoutable.HorizontalAlignmentPropertyLayoutable.VerticalAlignmentPropertyLayoutable.UseLayoutRoundingPropertyLayoutable.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.WidthLayoutable.HeightLayoutable.MinWidthLayoutable.MaxWidthLayoutable.MinHeightLayoutable.MaxHeightLayoutable.MarginLayoutable.HorizontalAlignmentLayoutable.VerticalAlignmentLayoutable.DesiredSizeLayoutable.IsMeasureValidLayoutable.IsArrangeValidLayoutable.UseLayoutRoundingLayoutable.EffectiveViewportChangedLayoutable.LayoutUpdatedVisual.BoundsPropertyVisual.ClipToBoundsPropertyVisual.ClipPropertyVisual.IsVisiblePropertyVisual.OpacityPropertyVisual.OpacityMaskPropertyVisual.EffectPropertyVisual.HasMirrorTransformPropertyVisual.RenderTransformPropertyVisual.RenderTransformOriginPropertyVisual.FlowDirectionPropertyVisual.VisualParentPropertyVisual.ZIndexPropertyVisual.GetFlowDirection(Visual)Visual.SetFlowDirection(Visual, FlowDirection)Visual.InvalidateVisual()Visual.Render(DrawingContext)Visual.AffectsRender<T>(params AvaloniaProperty[])Visual.OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs)Visual.InvalidateMirrorTransform()Visual.BoundsVisual.ClipToBoundsVisual.ClipVisual.IsEffectivelyVisibleVisual.IsVisibleVisual.OpacityVisual.OpacityMaskVisual.EffectVisual.HasMirrorTransformVisual.RenderTransformVisual.RenderTransformOriginVisual.FlowDirectionVisual.ZIndexVisual.VisualChildrenVisual.VisualRootVisual.BypassFlowDirectionPoliciesVisual.AttachedToVisualTreeVisual.DetachedFromVisualTreeStyledElement.DataContextPropertyStyledElement.NamePropertyStyledElement.ParentPropertyStyledElement.TemplatedParentPropertyStyledElement.ThemePropertyStyledElement.BeginInit()StyledElement.EndInit()StyledElement.ApplyStyling()StyledElement.InitializeIfNeeded()StyledElement.OnDataContextBeginUpdate()StyledElement.OnDataContextEndUpdate()StyledElement.OnInitialized()StyledElement.NameStyledElement.ClassesStyledElement.DataContextStyledElement.IsInitializedStyledElement.StylesStyledElement.StyleKeyStyledElement.ResourcesStyledElement.TemplatedParentStyledElement.ThemeStyledElement.LogicalChildrenStyledElement.PseudoClassesStyledElement.StyleKeyOverrideStyledElement.ParentStyledElement.ActualThemeVariantStyledElement.AttachedToLogicalTreeStyledElement.DetachedFromLogicalTreeStyledElement.DataContextChangedStyledElement.InitializedStyledElement.ResourcesChangedStyledElement.ActualThemeVariantChangedAnimatable.TransitionsPropertyAnimatable.OnPropertyChangedCore(AvaloniaPropertyChangedEventArgs)Animatable.TransitionsAvaloniaObject.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.InheritanceParentAvaloniaObject.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
ActiveFlowAnimationCount
Gets the number of edges currently with active flow animations.
public int ActiveFlowAnimationCount { get; }
Property Value
Animations
Gets the animation manager for controlling animations.
public AnimationManager Animations { get; }
Property Value
BackgroundRenderers
Gets the background renderer registry for custom background rendering.
public BackgroundRendererRegistry BackgroundRenderers { get; }
Property Value
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
CommandHistory
Gets the command history for undo/redo operations.
public CommandHistory CommandHistory { get; }
Property Value
ConnectionValidator
Gets or sets the connection validator for validating new connections.
public IConnectionValidator? ConnectionValidator { get; set; }
Property Value
ContextMenuManager
Gets the context menu manager for customizing context menus.
public FlowCanvasContextMenu ContextMenuManager { get; }
Property Value
CurrentInputState
Gets the current input state name (for debugging).
public string CurrentInputState { get; }
Property Value
CurrentZoom
Gets the current zoom level.
public double CurrentZoom { get; }
Property Value
DataFlow
Gets the graph executor for data flow processing. Returns null if data flow has not been enabled.
public GraphExecutor? DataFlow { get; }
Property Value
DebugRenderingPerformance
Gets or sets whether to output rendering performance diagnostics.
public bool DebugRenderingPerformance { get; set; }
Property Value
EdgeEffects
Gets the edge effects manager for rainbow and pulse effects.
public EdgeEffectsManager EdgeEffects { get; }
Property Value
Remarks
The EdgeEffectsManager automatically handles:
- Rainbow color cycling (RainbowEffect)
- Pulsing opacity (PulseEffect)
EdgeFlowAnimations
Gets the edge flow animation manager for automatic style-based animations.
public EdgeFlowAnimationManager EdgeFlowAnimations { get; }
Property Value
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
Graph
The graph to display and edit.
public Graph? Graph { get; set; }
Property Value
Groups
Gets the group manager for advanced group operations.
public GroupManager Groups { get; }
Property Value
IsDataFlowEnabled
Gets whether data flow is enabled for this canvas.
public bool IsDataFlowEnabled { get; }
Property Value
IsDirectRenderingEnabled
Gets whether direct rendering mode is enabled.
public bool IsDirectRenderingEnabled { get; }
Property Value
LayoutTransitions
Gets the layout transition manager for animating layout/arrange operations.
public LayoutTransitionManager LayoutTransitions { get; }
Property Value
NodeRenderers
Gets the node renderer registry for registering custom node types.
public NodeRendererRegistry NodeRenderers { get; }
Property Value
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
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
Routing
Gets the edge routing manager for controlling edge routing.
public EdgeRoutingManager Routing { get; }
Property Value
Selection
Gets the selection manager for managing node and edge selection.
public SelectionManager Selection { get; }
Property Value
Settings
Settings for the canvas appearance and behavior.
public FlowCanvasSettings Settings { get; set; }
Property Value
ShapeRenderers
Gets the shape renderer registry for registering custom shape types.
public ShapeRendererRegistry ShapeRenderers { get; }
Property Value
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
Viewport
Gets the viewport state for external components (e.g., minimap).
public ViewportState Viewport { get; }
Property Value
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
groupIdstringThe ID of the target group.
nodeIdsIEnumerable<string>The IDs of the nodes to add.
AddSelectedToGroup(string)
Adds selected nodes to the specified group.
public void AddSelectedToGroup(string groupId)
Parameters
groupIdstringThe 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
edgeEdgeThe edge to animate.
targetColorColorTarget color.
durationdoubleAnimation duration in seconds (default: 0.3).
onCompleteActionOptional 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
edgeEdgeThe edge to animate.
durationdoubleAnimation duration in seconds (default: 0.3).
onCompleteActionOptional 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
edgeEdgeThe edge to animate.
durationdoubleAnimation duration in seconds (default: 0.3).
onCompleteActionOptional 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
edgeEdgeThe edge to animate.
pulseCountintNumber of pulse cycles (default: 2).
onCompleteActionOptional callback when animation completes.
AnimateGroupCollapse(string, double, Action?)
Animates a group collapsing with sequenced transitions:
- Children nodes and edges fade out together
- Group shrinks
public void AnimateGroupCollapse(string groupId, double duration = 0.5, Action? onComplete = null)
Parameters
groupIdstringThe ID of the group to collapse.
durationdoubleTotal animation duration in seconds (default: 0.5).
onCompleteActionOptional callback when animation completes.
AnimateGroupExpand(string, double, Action?)
Animates a group expanding with sequenced transitions:
- Group grows
- Children nodes and edges fade in together
public void AnimateGroupExpand(string groupId, double duration = 0.5, Action? onComplete = null)
Parameters
groupIdstringThe ID of the group to expand.
durationdoubleTotal animation duration in seconds (default: 0.5).
onCompleteActionOptional 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
nodeNodeThe node to animate.
durationdoubleAnimation duration in seconds (default: 0.3).
onCompleteActionOptional 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
nodeNodeThe node to animate.
durationdoubleAnimation duration in seconds (default: 0.2).
onCompleteActionOptional 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
nodeNodeThe node to animate.
targetPositionPointTarget position in canvas coordinates.
durationdoubleAnimation duration in seconds (default: 0.3).
easingFunc<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
nodesIEnumerable<Node>The nodes to animate.
durationdoubleAnimation duration per node in seconds (default: 0.3).
staggerdoubleDelay between each node's animation start (default: 0.05).
onCompleteActionOptional 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
nodesIEnumerable<Node>The nodes to animate.
durationdoubleAnimation duration per node in seconds (default: 0.2).
staggerdoubleDelay between each node's animation start (default: 0.03).
onCompleteActionOptional 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
nodePositionsIReadOnlyDictionary<Node, Point>Dictionary mapping nodes to their target positions.
durationdoubleAnimation duration in seconds (default: 0.3).
easingFunc<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
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
groupIdstringThe 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
edgeEdgeThe 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
nodeNodeThe 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
shapeShapeElementThe shape to edit.
Returns
- bool
True if editing started successfully.
CanvasToScreen(Point)
Converts canvas coordinates to screen coordinates.
public Point CanvasToScreen(Point canvasPoint)
Parameters
canvasPointPointPosition 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
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
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
xdoubleX coordinate in canvas coordinates.
ydoubleY coordinate in canvas coordinates.
durationdoubleAnimation duration in seconds (default: 0.3).
easingFunc<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
durationdoubleAnimation duration in seconds (default: 0.3).
easingFunc<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
nodeNodeThe node to center on.
durationdoubleAnimation duration in seconds (default: 0.3).
easingFunc<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
Returns
- InputNodeProcessor<T>
The created processor.
Type Parameters
TThe 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
Returns
- OutputNodeProcessor<T>
The created processor.
Type Parameters
TThe 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
nodeNodeThe node being edited.
ExecuteFromNode(string)
Executes only nodes affected by a change to the specified node.
public void ExecuteFromNode(string nodeId)
Parameters
nodeIdstringThe 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
durationdoubleAnimation duration in seconds (default: 0.3).
easingFunc<double, double>Optional easing function.
GetAllGroups()
Gets all groups in the graph.
public IEnumerable<Node> GetAllGroups()
Returns
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
ePointerEventArgsThe 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
canvasPointPointThe 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
groupIdstringThe ID of the group.
Returns
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
nodeIdstringThe 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
nodeIdstringThe 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
nodeIdstringThe node ID.
Returns
- T
The processor, or null if not found or wrong type.
Type Parameters
TThe processor type.
GetShapeVisual(string)
Gets the visual control for a shape element by its ID.
public Control? GetShapeVisual(string shapeId)
Parameters
shapeIdstringThe 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
ePointerEventArgsThe 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
ePointerEventArgsThe 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
ePointerEventArgsThe 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
GroupSelected(string?)
Groups the selected nodes into a new group.
public Node? GroupSelected(string? groupLabel = null)
Parameters
groupLabelstringOptional 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
loadXamlboolShould the XAML be loaded into the component.
IsEditingNodeLabel(Node)
Gets whether a node is currently in edit mode.
public bool IsEditingNodeLabel(Node node)
Parameters
nodeNodeThe 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
nodeIdstringThe ID of the node to check.
Returns
OnAttachedToVisualTree(VisualTreeAttachmentEventArgs)
Called when the control is added to a rooted visual tree.
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
Parameters
eVisualTreeAttachmentEventArgsThe 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
eKeyEventArgsData about the event.
OnPropertyChanged(AvaloniaPropertyChangedEventArgs)
Called when a avalonia property changes on the object.
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
Parameters
changeAvaloniaPropertyChangedEventArgsThe property change details.
OnSizeChanged(SizeChangedEventArgs)
Raises the Avalonia.Controls.Control.SizeChanged event.
protected override void OnSizeChanged(SizeChangedEventArgs e)
Parameters
eSizeChangedEventArgsThe 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
processorINodeProcessorThe processor to register.
RemoveNodesFromGroup(IEnumerable<string>)
Removes nodes from their parent group.
public void RemoveNodesFromGroup(IEnumerable<string> nodeIds)
Parameters
nodeIdsIEnumerable<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
screenPointPointPosition 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
screenXdoubleX position in viewport coordinates.
screenYdoubleY 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
SetZoom(double)
Sets the zoom level.
public void SetZoom(double zoom)
Parameters
zoomdouble
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
edgeEdgeThe edge to animate.
speeddoubleSpeed of the flow animation (default: 50).
reverseboolIf 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
animationEdgeFlowAnimationThe animation to stop.
ToggleGroupCollapse(string)
Toggles the collapsed state of a group.
public void ToggleGroupCollapse(string groupId)
Parameters
groupIdstringThe 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
nodeIdstringThe 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
targetZoomdoubleTarget zoom level.
durationdoubleAnimation duration in seconds (default: 0.2).
easingFunc<double, double>Optional easing function.
Events
ConnectEnd
Event raised when connection creation ends.
public event EventHandler<ConnectEndEventArgs>? ConnectEnd
Event Type
ConnectStart
Event raised when connection creation starts.
public event EventHandler<ConnectStartEventArgs>? ConnectStart
Event Type
ConnectionCompleted
Event raised when a connection is successfully completed.
public event EventHandler<ConnectionCompletedEventArgs>? ConnectionCompleted
Event Type
ConnectionRejected
Event raised when a connection is rejected by the validator.
public event EventHandler<ConnectionRejectedEventArgs>? ConnectionRejected
Event Type
DebugOutput
Event raised when debug performance info is available. Subscribe to this to receive performance metrics.
public event Action<string>? DebugOutput
Event Type
EdgeClicked
Event raised when an edge is clicked.
public event EventHandler<EdgeClickedEventArgs>? EdgeClicked
Event Type
EdgeDisconnected
Event raised when an edge is disconnected.
public event EventHandler<EdgeDisconnectedEventArgs>? EdgeDisconnected
Event Type
EdgeLabelEditRequested
Event raised when a user double-clicks an edge label to edit it.
public event EventHandler<EdgeLabelEditRequestedEventArgs>? EdgeLabelEditRequested
Event Type
EdgeReconnected
Event raised when an edge is reconnected to a different port.
public event EventHandler<EdgeReconnectedEventArgs>? EdgeReconnected
Event Type
GroupCollapsedChanged
Event raised when a group's collapsed state changes.
public event EventHandler<GroupCollapsedEventArgs>? GroupCollapsedChanged
Event Type
InputStateChanged
Event raised when the input state changes.
public event EventHandler<StateChangedEventArgs>? InputStateChanged
Event Type
NodeDragStart
Event raised when node dragging starts.
public event EventHandler<NodeDragStartEventArgs>? NodeDragStart
Event Type
NodeDragStop
Event raised when node dragging stops.
public event EventHandler<NodeDragStopEventArgs>? NodeDragStop
Event Type
NodeLabelEditRequested
Event raised when a user double-clicks a node to edit its label.
public event EventHandler<NodeLabelEditRequestedEventArgs>? NodeLabelEditRequested
Event Type
NodeResized
Event raised when a node is resized.
public event EventHandler<NodeResizedEventArgs>? NodeResized
Event Type
NodeResizing
Event raised when a node is being resized (in progress).
public event EventHandler<NodeResizingEventArgs>? NodeResizing
Event Type
NodesDragged
Event raised when nodes have been dragged to a new position.
public event EventHandler<NodesDraggedEventArgs>? NodesDragged
Event Type
SelectionChanged
Event raised when the selection changes.
public event EventHandler<SelectionChangedEventArgs>? SelectionChanged
Event Type
ShapeResized
Event raised when a shape resize is completed.
public event EventHandler<ShapeResizedEventArgs>? ShapeResized
Event Type
ShapeResizing
Event raised when a shape is being resized (in progress).
public event EventHandler<ShapeResizingEventArgs>? ShapeResizing
Event Type
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
ViewportChanged
Event raised when the viewport changes (pan, zoom).
public event EventHandler<ViewportChangedEventArgs>? ViewportChanged