Lodeon
❔ ✅ WPF Node Editor - Who should handle connection between nodes
Note: this is the first post I publish. If this is not the correct place for it or something is wrong about it, I will edit/remove it
I am creating a node graph editor in c# WPF similar to Unity's Shader Graph. There is a canvas where all nodes are displayed. I have a "Node" UserControl which has a "Connector" UserControl. Connectors should be able to be dragged and dropped one on another to connect two nodes. When two nodes are connected a line should be drawn between the two connectors.
Im kind of new to WPF so it's hard for me to understand which control should handle which part of the code.
Who should handle the drag/drop and line drawing? Should the connector being dropped on another draw the line between the two?
Should the parent node be responsible for the dragging and dropping of the connector and line drawing? Or should the node notify the canvas about the event and make it so the canvas handles all of the node's connections?
Most important question: since there will be a variable number of connectors that will be generated at runtime, is it even a good idea to separate the connectors from the node control?
Thanks in advance
10 replies