AutomaticPortCreation in WPF Diagram (SfDiagram)
9 Jun 20211 minute to read
Diagram provides an option to create a port dynamically by clicking and dragging the mouse over any node or connector. This behavior is disabled by default and can be enabled by using
GraphConstraints.AutomaticPortCreation. To draw connector, you need to set the
DrawingTool properties of diagram.
<!--Enables AutomaticPortCreation of SfDiagram to create port at runtime while making connections.--> <syncfusion:SfDiagram x:Name="diagram" PortVisibility="Visible" Tool="ContinuesDraw" DrawingTool="Connector" Constraints="Default,AutomaticPortCreation"/>
//We need to enable tool and drawingtool to draw connector by clicking and dragging the mouse over the node. diagram.Tool = Tool.ContinuesDraw; diagram.DrawingTool = DrawingTool.Connector; //Enables AutomaticPortCreation of SfDiagram to create port at runtime while making connections. diagram.Constraints |= GraphConstraints.AutomaticPortCreation;
Diagram provides the support to drag the port interactively within the limit.
DockPort, port can be dragged within the node bounds.
ConnectorPort, port can be dragged anywhere on the connector.