Skip to content

Custom Nodes

A NodeTemplate renders your own markup inside each node: here a colour node with a working colour picker and two labelled source handles, while every other node falls back to the built-in look through BlowDefaultNode.

Crimson
#dc2626
Emerald
#10b981
Mixer
Palette
bit Blow

Try it

  • Click the swatch on Crimson or Emerald and pick another colour: the swatch and the hex code under the name follow as you choose.
  • Hover the two handles on the right of a colour node: the tooltips name them Output A and Output B.
  • Drag from either handle to another node to connect it; each edge remembers which of the two it leaves from.
  • Drag a colour node by its name to move it - a press on the swatch opens the picker instead.
  • Tab to Crimson and press C: a connection starts from Output A and is announced by that name, and C again switches it to Output B. Keep pressing Tab until Palette has focus, then Enter connects and Escape gives up.

How it works

  • NodeTemplate is a RenderFragment<BlowNode> that replaces the content of every node; it switches on node.Type and reads its own payload from node.Data.
  • The template is part of the page, so @bind on the picker writes straight into the node's ColorData, and the re-render that follows redraws the node.
  • The picker carries the nodrag class (the canvas's NoDragClass), so pressing it neither selects nor drags the node.
  • BlowHandle goes anywhere in the template: Type and Position say what and on which side, Style="top:35%" moves it along that side, and an Id tells handles of the same type apart. The starting edges pick theirs with SourceHandle = "a" and "b".
  • Ports on the node model declares the two outputs as BlowPorts; a port's Label becomes its handle's tooltip and the name a screen reader hears when connecting from the keyboard.
  • Every other type is handed back to BlowDefaultNode, which draws the built-in content; Mixer's TargetPosition and SourcePosition put its handles on the left and right.
  • The template renders inside the node's own chrome - padding, border, background - and Width = 180 fixes the colour nodes' width. With a template set, the add-ons go in an explicit <ChildContent>.
An unhandled error has occurred. Reload 🗙