Highlight links (not selecting them)

Hi,
One of my requirements is to highlight links and nodes according to some logic.
Nodes are no-brainer because I can put anything I want in the DataTemplate like shapes and to have a trigger that show the “highlight shape” only when a property in the data is true.

Links are somewhat more complicated because there is a single LinkShape that has the actual link geometry. There is no way to get the geometry but to derive a class from LinkShape like so:

public class MyLinkShape : LinkShape {

public Geometry Data {

get { return (Geometry)GetValue(DataProperty); }

private set { SetValue(DataPropertyKey, value); }

}

public static readonly DependencyPropertyKey DataPropertyKey =

DependencyProperty.RegisterAttachedReadOnly("Data", typeof(Geometry), typeof(MyLinkShape), new UIPropertyMetadata(null));

public static readonly DependencyProperty DataProperty = DataPropertyKey.DependencyProperty;

protected override Geometry DefiningGeometry {

get {

Data = base.DefiningGeometry;

return base.DefiningGeometry;

}

}

}

I have to override DefiningGemoetry to cache the actual geometry each time it is changing.

I've then create the following DataTemplate for the link

<p =“p1” style=“line-height: 10px; font-size: x-small; “><font =“Apple-style-span” face=”‘Courier New’, Courier, mono”><span =“s1”> <<span =“s1”>DataTemplate<span =“s2”> x:<span =“s2”>Key=“DefaultLinkTemplate”>

<go:LinkPanel go:Part.SelectionElementName="Path">

<Path Stroke="{Binding Data.HighlightBrush}" StrokeThickness="6" Data="{Binding ElementName=Path, Path=Data}" />

<local:MyLinkShape x:Name="Path" go:LinkPanel.IsLinkShape="True" Stroke="{Binding Data.Fill}" StrokeThickness="3" />

<Polygon Fill="Black" Points="8 4 0 8 2 4 0 0" go:LinkPanel.Alignment="MiddleRight" go:LinkPanel.Index="-1" go:LinkPanel.Orientation="Along" />

</go:LinkPanel>

</DataTemplate>

This still does not give me the look I'm trying to achieve which is something like this:

======================

LightGreen

-----------------------------------------

Brown

----------------------------------------

LightGreen

=====================

Is this the right way to go to highlight links? Are there other ways?

Thank you,

Ido.

Take a look at the Piping sample. The LinkTemplate there (named “PipeTemplate”) has three separate go:LinkShapes, with stroke thicknesses of 1, 3, and 5, in order to produce a gradient effect across the width of each pipe, regardless of the orientation of the link segment.

The go:LinkPanel will automatically assign the same geometry to all three go:LinkShapes. So you don’t need to write any code at all!

Sorry I’ve missed that - You’r the best.

Thank you,
Ido.