We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to add multiple ports for Node in the WPF Diagram (SfDiagram)?

Platform: WPF |
Control: SfDiagram

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);

 

A close up of a logo

Description automatically generated

View Sample in GitHub

2X faster development

The ultimate WPF UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile