Link not snapping on port with relinking tool

Hi Walter,

Am trying to implement relinking existing links using the RelinkingTool. I am seeing the diamond handle for relinking, but after dragging the diamond, the blue temporary link appears but doesn’t “snap” to any node. I have looked at the FlowChart example too.

What I tried so far is :- I have AllowRelink = true, set RelinkableFrom=“True” and RelinkableTo=“True” on the link Template. The ports also have LinkableFrom and LinkableTo set to true. Valid portIds exist.

Could you help me understand how to get relinking working?

Regards,
Vibha

If you try relinking in the State Chart sample, does that work for you?

If so, how does its node template’s port declarations differ from yours, ignoring the contents of the nodes, but just concentrating on linking and relinking?

Yes I have tried the state chart example. It has no ports and no port related code in template, hence I was seeing the FlowChart example. Still investigating what is likely causing the issue.

Yes the State Chart Nodes each have a single port.

If you want an example of relinking where nodes have multiple ports, look at the Logic Circuit sample.

I have not been able to solve this issue, I verified all Mouseup events and dont see any problem where I stop the tool abrubtly or cancel. In LinkRELINKED event I see that the ToNode still shows the originalNode and not the new node and port Intend the link to snap to.

In GoWpfDemo, I modified the DraggableLink sample by adding a LinkRelinked event handler on myDiagram. (Note that Route.RelinkableFrom and Route.RelinkableTo are already set to true on the Link.Route.)

      myDiagram.LinkRelinked += MyDiagram_LinkRelinked;
. . .
    private void MyDiagram_LinkRelinked(object sender, DiagramEventArgs e) {
      var link = e.Part as Link;
      System.Diagnostics.Trace.WriteLine("LinkRelinked " + link.FromPortId + " " + link.ToPortId);
    }

The appropriate messages appeared as the user reconnects the selected Link to add different port element perhaps on a different node. (Note that the default port has an empty string identifier.)

Another possibility: have you implemented a link validation predicate that disallows some connections? Maybe that’s why the user cannot do the relinking in your app.

Yes I do have link validations implemented inside the LinkingTool, but they don’t seem a problem here. They are not even called when I do the relinking. I added the same piece of code in LinkRelinked event and see that correct link and port is shown in the trace, but on the UI it doesnt attach to the new node and port.

If you have custom link validation in the LinkingTool, you probably want the same link validation in the RelinkingTool.