Prevent Link overlap + highlight all links

I’m new to using this great control. My data structure is basically each node can have multiple parents and have multiple children. I’m using a Tree Layout. I would like to accomplish the following two behaviors :

  1. I want to NOT overlap between nodes.

  2. Whenever a link is selected, I want all of it’s links to be highlighted in a different color.

Any help would greatly be appreciated.


Well, TreeLayout should meet your requirement about no overlapping nodes, but because TreeLayout assumes the graph is structured as a tree but your graph is not tree-like at all, there may be links crossing over nodes. LayeredDigraphLayout will produce a better result, although if your graph is large the layout will be very slow.

I don’t understand your second requirement.
If your second requirement was meant to be about when a Node (not a Link) is selected the Links coming from it should be drawn in a different color, that is easy to implement purely in XAML.
Add a converter:

    <go:BooleanBrushConverter x:Key="theBrushConverter" FalseBrush="Black" TrueBrush="Red" />

Then add a Binding to your Link DataTemplate:

<go:LinkPanel . . .> . . . <go:LinkShape x:Name="Path" StrokeThickness="2" Stroke="{Binding Path=Link.FromNode.IsSelected, Converter={StaticResource theBrushConverter}}" /> . . . </go:LinkPanel>
But there are a lot of other possibilities, and I’m not sure that this is what you want.

My bad about the second part. Your solution worked almost perfectly. The only issue is, because of the overlap of some links, when the selected node’s links are highlighted, some parts of them aren’t top-most so the red highlights don’t connect fully. How can I address that?

As for the first part, I’m going to play with the LayeredDigraphLayout. Generally, the trees will not be that large so it may not be too slow for me. At least I hope so :)

Thanks for the help

Also I wanted both From and To links highlighted not just From.

I’m sing the LayeredDigraphLayout and it works perfectly by the way Thumbs Up


Well, you could also bind go:Part.LayerName to either “” or “Foreground”, again assuming that you are not already using the “Foreground” layer for anything else. Look at the documentation for the BooleanStringConverter class for exactly this example.

If you want to have these values when either the “FromNode” or the “ToNode” are selected, that gets more complicated. In WPF you could try using a MultiBinding and a IMultiBindingConverter. In Silverlight I don’t know – you probably can’t use Binding at all and instead implement some code in a Diagram.SelectionChanged event handler.