Category / Section
How to add multiple ports for Node in the WPF Diagram (SfDiagram)?
1 min read
The Multiple number of ports can be added to the node by using the PortCollection class in WPF Diagram (SfDiagram).
C#
SfDiagram diagram = new SfDiagram(); diagram.Nodes = new ObservableCollection<NodeViewModel>(); diagram.PortVisibility = PortVisibility.Visible; NodeViewModel node = new NodeViewModel() { UnitHeight = 100, UnitWidth = 100, OffsetX = 200, OffsetY = 200, Ports = new PortCollection() { new NodePortViewModel() { NodeOffsetX = 0, NodeOffsetY = 0, }, new NodePortViewModel() { NodeOffsetX = 0.5, NodeOffsetY = 0, }, new NodePortViewModel() { NodeOffsetX = 1, NodeOffsetY = 0, }, new NodePortViewModel() { NodeOffsetX = 0, NodeOffsetY = 0.5, }, new NodePortViewModel() { NodeOffsetX = 1, NodeOffsetY = 0.5, }, new NodePortViewModel() { NodeOffsetX = 0, NodeOffsetY = 1, }, new NodePortViewModel() { NodeOffsetX = 0.5, NodeOffsetY = 1, }, new NodePortViewModel() { NodeOffsetX = 1, NodeOffsetY = 1, }, }, }; (diagram.Nodes as ObservableCollection<NodeViewModel>).Add(node);