Empty
A canvas that starts with no nodes: add them at runtime by appending to the Nodes list, then connect them. OnNodesInitialized reports when what you added has been measured, and NodesInitialized answers the same question later - the cue for any work that needs real node sizes.
Press Tab to move between the nodes and edges of the diagram.
Press Enter or Space to select it, Shift with Enter to add it to the selection, the arrow keys to move the selected nodes, Delete to remove them and Escape to clear the selection. Press C to start a connection from it.
Press Enter or Space to select it, Delete to remove it and Escape to clear the selection. Press C to move its end to another node.
bit BlowTry it
- Press Add node a few times: each node lands at a random spot. Drag from one node's handle to another's to connect them.
- Watch the toolbar as the first node lands: once it has been measured,
OnNodesInitializedfires, the counter goes up and the size the browser measured is shown. Adding more nodes does not raise it again. - Press Line up to set the nodes side by side, spaced by their measured widths, and bring the row into view. On an empty canvas it does nothing.
- Press Clear to empty both lists, then add a node again: the counter goes up a second time.
How it works
NodesandEdgesstart as empty lists. Adding aBlowNodeto the list is all it takes: on its next render the canvas draws the node and measures it, with noRefreshcall needed.- Without
FitViewOnInitthe canvas opens at the default viewport - no pan, zoom 1 - so flow position (0, 0) is the pane's top-left corner. OnNodesInitializedis raised when the canvas goes from having nothing measured to every visible node measured. A node added later is measured straight after the render that draws it, so here the event comes once per empty canvas.BlowNode.Measuredholds the size, in flow units.NodesInitializedgives the same answer as a property, for code that runs later: Line up checks it before readingMeasured.Width, and it is false while the canvas is empty.FitViewAsyncwithBlowFitViewOptions { MaxZoom = 1, Duration = 300 }eases the row into view without zooming in past full size.