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

Moving LineConnectors with ports at runtime

I have a scenario where I am creating a connection between 2 nodes, but the connection line needs to be segmented.  To accomplish this, I created a port on a connection line between the 2 nodes with the following code

        Dim headnode As New Node()

        headnode.Shape = Shapes.RoundedRectangle

        headnode.Label = "Head Node"

        headnode.Height = 100

        headnode.Width = 100

        headnode.OffsetX = 200

        headnode.OffsetY = 200



        Dim tailnode As New Node()

        tailnode.Shape = Shapes.RoundedRectangle

        tailnode.Label = "Tail Node"

        tailnode.Height = 100

        tailnode.Width = 100

        tailnode.OffsetX = 400

        tailnode.OffsetY = 50



        Dim line As New LineConnector()

        Dim port As New ConnectionPort()

        port.PortStyle.Stroke = New SolidColorBrush(Colors.OrangeRed)

        port.PortStyle.Fill = New SolidColorBrush(Colors.OrangeRed)

        port.Width = 10

        port.Height = 10

        port.PortOffset = 0.0

        port.PortVisibility = PortVisibility.AlwaysVisible


        line.ConnectorType = ConnectorType.Straight

        line.TailNode = tailnode

        port.Edge = line



        Dim line1 As New LineConnector()

        line1.LineStyle.Stroke = New SolidColorBrush(Colors.Brown)

        line1.TailDecoratorStyle.Stroke = New SolidColorBrush(Colors.Brown)

        line1.TailDecoratorStyle.Fill = New SolidColorBrush(Colors.Brown)

        line1.TailDecoratorShape = Syncfusion.Windows.Diagram.DecoratorShape.None

        line1.ConnectionTailPort = port

        line1.ConnectorType = ConnectorType.Straight

        line1.HeadNode = headnode


When I select the LineConnector attached to the Tail Node, and reposition the line, the port moves also which is what I want.  However, if I select the LineConnector, attached to the Head Node, and reposition the line, the line detaches from the port.  Is there a way to either allow the port to be relocated if either the Head or Tail LineConnector is repositioned?  Or is there a way to allow the port to be dragged to a new location on the View?

2 Replies

TL Todd Lichtas April 17, 2013 05:20 PM UTC

I came up with a solution to this by using another type of node rather than Ports on a Line.  This allowed me to have a segmented line with one or more "connectionNodes" between the "actual" nodes.

SC Sudhakar C Syncfusion Team April 19, 2013 04:14 AM UTC

Hi Todd,


Thanks for the update. This will be work fine. And also, please let us know if you have any other concerns. As always, we will be happy to assist you. Thanks for using Syncfusion Products.




Sudhakar C

Live Chat Icon For mobile
Up arrow icon