Single link from a node port

Hello everyone,

I have a diagram and I want a node to have ONLY ONE link that comes out from a node port.
I’m using a GraphLinksModel.

Should I create a custom (Re)LinkingTool that check in the LinksSource if there is already a link that start from the node?
Is there a better way to do that?
Is there an example that implement that feature?

Thank you very much

Andrew

If you don’t have to worry about any links going into that port, you can just set go:Node.LinkableMaximum=“1” on that port element.

If you may have a variable number of links going into that port, you can override [Re]LinkingTool.IsValidLink to check for the cases you want to allow. There are some examples of this in the demo app.

I’m having some troubles implementing it.

I have these two ports in my Node DataTemplate:


How can I get the link PortIds from inside the function IsValidLink in LinkingTool? (I should read “In” or “Out” somewhere).

If you want to limit the number of links that can be drawn coming out of your “Out” port, you just need to set go:Node.LinkableMaximum=“1”. That is possible because you are not allowing any links to go into that “Out” port.

Thank you walter, I’ll try that way.

But can you tell me how can I get the portId on the from/to node when I’m inside the function IsValidLink in LinkingTool?


Thanks again

Just get the go:Node.PortId attached property from the FrameworkElement that is the port, for example:
Node.GetPortId(fromport)

Right.

Thank you very much!