Skip to content

Custom Connection Lines & Live Connection State

The line drawn while you make a connection, three ways: the built-in line, the built-in line restyled with ConnectionLineStyle and ConnectionLineClass, or SVG of your own from ConnectionLineTemplate. OnConnectionChange reports the live BlowConnectionLineContext - where the line runs, and whether it could connect where it ends.

Drag from here
Open target
Open target
🔒 Locked
Connection state
idle - drag from a handle
bit Blow

Try it

  • Drag from the bottom handle of Drag from here: a dashed gradient line follows the pointer, and its end dot turns green over a handle that would accept the connection. Release on the top handle of an Open target to connect.
  • Watch Connection state as you drag: where the line starts and ends, whether it could connect, and why not - RejectedByRule over the Locked node, SameHandleType over an Open target's bottom handle (another source), Duplicate over a target you have already connected, and no handle in reach out on the empty pane.
  • Press Escape while dragging: the line disappears, nothing connects and the panel goes back to idle.
  • Switch Line to Restyled built-in line for a thicker amber line with marching dashes, or to Built-in line for the plain line in the theme's connection colour.
  • Pick another Path - Straight, Step, SmoothStep, SimpleBezier - and the line takes that shape, in all three modes.
  • Raise Drag threshold to 40, press a handle and move slowly: no line is drawn, and the panel's to point stays put, until the pointer has travelled 40 pixels.

How it works

  • ConnectionLineType (default Bezier) is the built-in line's path; the template hands the same BlowEdgeType to BlowEdgePath.Compute, so the Path select shapes both.
  • ConnectionLineStyle is an inline style for the built-in line - here stroke:#f59e0b;stroke-width:3 - and ConnectionLineClass adds classes to it - here one whose CSS animates the dashes. Both are ignored while a template draws the line.
  • ConnectionLineTemplate is a RenderFragment<BlowConnectionLineContext> drawn in the canvas's edge layer, so it renders SVG in flow coordinates. This page passes a Razor template only while Custom template is chosen; otherwise the parameter is null and the built-in line is drawn.
  • BlowConnectionLineContext carries FromNode, FromHandle, FromHandleType, FromPosition, From, To, ToPosition, IsValid and Rejection.
  • OnConnectionChange is raised when a connection starts, on every move while it is dragged, and once with null when it ends.
  • IsValid is true when the line ends on a handle that would accept it, or within ConnectionRadius (20 screen pixels) of one. Rejection, a BlowConnectionRejection, says why the nearest handle would refuse it: RejectedByRule when IsValidConnection returned false, SameHandleType because ConnectionMode is Strict by default, Duplicate because PreventDuplicateEdges is on by default. It is None when no handle is near.
  • IsValidConnection refuses every connection whose target node's Data is "locked".
  • ConnectionDragThreshold (default 1) is how far, in screen pixels, the pointer has to travel before the line is drawn and its moves reported, so a click on a handle does not flash a line.
  • Escape abandons the gesture in progress - nothing to wire up.
An unhandled error has occurred. Reload 🗙