Relinking connection

Hi,

I have three nodes say A, B & C with following properties set for their corresponding port:

1)A → LinkableFrom=“True” & LinkableTo=“False”
2)B → LinkableFrom=“False” & LinkableTo=“True”
3)C → LinkableFrom=“True” & LinkableTo=“True”

As seen in the picture Node C is connected to Node B. But when I am relinking connection from B end and points towards A, connection becomes invalid. It makes sense as A is having LinkableTo=“False”. But since the connection is from C to A it is expected to have a valid connection while relinking. So currently its not possible to relink the connection to A. The whole scenario is explained in below pictures also:

image

RelinkIssue(2)

Please advice what changes we need to do, so that it will be valid connection.

Thanks

Set both LinkableFrom and LinkableTo attached properties to true.

Override LinkingTool.IsValidLink to return true when you want.

We tried above approach, by setting LinkableFrom and LinkableTo to True. Now we are able to connect

But how can i reverse the connection direction?.

Thanks

If you only want new links to be drawn in the “forwards” direction, set LinkingTool.Direction to LinkingDirection.ForwardsOnly.
http://www.goxam.com/3.0/apiCore/#Northwoods.GoWPF~Northwoods.GoXam.Tool.LinkingTool~Direction.html

Direction is part of LinkingTool and it will be set during the creation of a new Link, whereas we are doing Relinking here.

You may need to override RelinkingTool.IsValidLink to return false for those situations that you do not want to allow.

Scenario here is
1)A → LinkableFrom=“True” & LinkableTo=“False”
2)B → LinkableFrom=“False” & LinkableTo=“True”
3)C → LinkableFrom=“True” & LinkableTo=“True”

Valid connection is created between B and C (refer the first diagram in my initial comments). Then try to relink the connection from B to A (after making LinkableTo and LinkableFrom to True), i am able to connect. Now the issue here is the link direction should change when connection from B to A. (Port in A should be source and the port in C should be destination).

How can i achieve this?.

Thanks

Oh, so are you saying that link validity isn’t wrong, but you just want a different result in some relinking cases. I suppose in a Diagram.LinkRelinked event listener you could reverse the link by swapping the Link.FromNode and Link.ToNode. In the link data, not by trying to set those read-only properties.