Port Conected to Link

In FlowChart sample ports are highlighted when Mouse hovers over the node and it is done with method SetPortsVisible. How can one figure out if a port is already connected in SetPortsVisible method, so as to not to set it visible and set visible only the ports that are not yet connected.

First of all you need to bind each Port to another Property. Because the Visibility (Stroke) is now based on the Node.Tag. So they all are visible or not.

Then in the SetPortsVisible you need to FindLinksIntoPort for each port.

With that you can set the Node.Property (for each sport 1 property) visibility.

That’s how it could be done, as far as I know.

Thank you, icvanee – that’s basically the right idea.

Instead of use the Node.Tag property to control the visibility of all ports using the data-binding of Visibility to Node.Tag using a BooleanVisibilityConverter, it’s probably easiest to set the Visibility directly in code.

You can find all of the ports on a Node by iterating over them.
I haven’t tested this code, but it ought to be something like:

foreach (FrameworkElement port in aNode.Ports) { string portid = Node.GetPortId(port); bool haslinks = (aNode.FindLinksConnectedWith(port).FirstOrDefault() != null); if (haslinks) { port.Visibility = Visibility.Collapsed; } else { port.Visibility = Visibility.Visible; } }

Thanks everyone,



FindLinksConnectedWithPort is what I needed