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 validate the connection and port visibility in WPF Diagram (SfDiagram)?

Platform: WPF |
Control: SfDiagram

The ValidateConnection is one of the PortVisibility which is used to achieve logical gates functionality in ports, and it controls over visibility of port based on the connector ends in WPF Diagram (SfDiagram).

  • Port which is having OutPort in constraints will be visible only in new connection (Source thumb dragging).
  • Port which is having InPort in constraints will be visible only in end thumb dragging.

The ValidateConnection virtual method is used to make decision on creating/editing the connection at runtime.

  • Restrict the number of connections in port or node.
  • Decide on target/source port or node of connection.

For example, InPort, OutPort, and number of connections to the port restriction is represented in the sample. Refer to the code example and sample as follows.

C#

// Validate the connection when connector endpoints are dragged
protected override void ValidateConnection (ConnectionParameter args)
{
  if (args.TargetPort is PortVM)
  {
    var port = args.TargetPort as PortVM;
    if (!port.CanCreateConnection(args.Connector as IConnector))
    {
      args.TargetPort = null;
    }
  }
  base.ValidateConnection(args);
}

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