Link not showing in WPF

Hi Walter,

I'm having a strange problem with the link. The datatemplate for the link in Silverlight seems to work fine. It draws the orthogonal line with arrowhead and labels between nodes. The same link template in WPF is drawing everything but the line between the nodes. It draws the arrows and the label, but not the line. I tried hardcoding the path, but that didn't work either. Any idea why this may be happening?
Below is the template:
<DataTemplate x:Key="linkTemplate"> <go:LinkPanel go:Part.SelectionElementName="Path" go:Part.SelectionAdorned="True" go:Part.Selectable="True" go:Part.LayerName="Background" Opacity="{Binding Data.Opacity}" > <go:Link.Route> <go:Route Routing="{Binding Data.Routing}" Curve="{Binding Data.Curve}" Corner="10" /> </go:Link.Route> <Path StrokeDashArray="{Binding Data.LinePattern, Converter={StaticResource patternToDashArrayConverter}}" go:LinkPanel.IsLinkShape="True" x:Name="Path" StrokeThickness="{Binding Data.LineThickness}" MouseLeftButtonDown="Path_MouseLeftButtonDown"> <Path.Stroke> <LinearGradientBrush StartPoint="0,0" EndPoint="0,1"> <GradientStop x:Name="Stop1" Color="{Binding Data.Self, Converter={StaticResource showConnectedConverter}}" Offset="0" /> <GradientStop x:Name="Stop2" Color="{Binding Data.Self, Converter={StaticResource showConnectedConverter}}" Offset="1" /> </LinearGradientBrush> </Path.Stroke> </Path> <Polyline StrokeThickness="{Binding Data.LineThickness}" Points="8 4 0 8 2 4 0 0" go:LinkPanel.Index="-1" go:LinkPanel.Alignment="Center" go:LinkPanel.Orientation="Along"> <Polyline.Visibility> <Binding ConverterParameter="From" Converter="{StaticResource arrowheadToVisibilityConverter}" Path="Data.Direction" /> </Polyline.Visibility> <Polyline.Fill> <LinearGradientBrush StartPoint="0,0" EndPoint="0,1"> <GradientStop x:Name="Stop1Left" Color="{Binding Data.Self, Converter={StaticResource showConnectedConverter}}" Offset="0" /> <GradientStop x:Name="Stop2Left" Color="{Binding Data.Self, Converter={StaticResource showConnectedConverter}}" Offset="1" /> </LinearGradientBrush> </Polyline.Fill> <i:Interaction.Triggers> <Behaviors:DoubleClickTrigger> <i:InvokeCommandAction Command="{Binding Data.DoubleClickCommand}" /> </Behaviors:DoubleClickTrigger> </i:Interaction.Triggers> </Polyline> <Polyline StrokeThickness="{Binding Data.LineThickness}" Points="0 4 8 0 6 4 8 8" go:LinkPanel.Alignment="Center" go:LinkPanel.Index="0" go:LinkPanel.Orientation="Along"> <Polyline.Visibility> <Binding ConverterParameter="To" Converter="{StaticResource arrowheadToVisibilityConverter}" Path="Data.Direction" /> </Polyline.Visibility> <Polyline.Fill> <LinearGradientBrush StartPoint="0,0" EndPoint="0,1"> <GradientStop x:Name="Stop1Right" Color="{Binding Data.Self, Converter={StaticResource showConnectedConverter}}" Offset="0" /> <GradientStop x:Name="Stop2Right" Color="{Binding Data.Self, Converter={StaticResource showConnectedConverter}}" Offset="1" /> </LinearGradientBrush> </Polyline.Fill> <i:Interaction.Triggers> <Behaviors:DoubleClickTrigger> <i:InvokeCommandAction Command="{Binding Data.DoubleClickCommand}" /> </Behaviors:DoubleClickTrigger> </i:Interaction.Triggers> </Polyline> <go:NodePanel Sizing="Auto" go:LinkPanel.Orientation="None" go:LinkPanel.Offset="10 NaN"> <i:Interaction.Triggers> <Behaviors:DoubleClickTrigger> <i:InvokeCommandAction Command="{Binding Data.DoubleClickCommand}" /> </Behaviors:DoubleClickTrigger> </i:Interaction.Triggers> <Rectangle Stroke="Gray" Fill="Gray" Opacity="0" /> <TextBlock go:Part.TextEditable="False" Visibility="{Binding Data.ShowLabel, Converter={StaticResource boolToVisibilityConverter}, Mode=TwoWay}" Text="{Binding Data.Name, Mode=TwoWay}" FontSize="9" TextWrapping="Wrap" TextAlignment="Center" Margin="10" > <TextBlock.Foreground> <SolidColorBrush Color="{Binding Data.Self, Converter={StaticResource showConnectedConverter}}" /> </TextBlock.Foreground> </TextBlock> </go:NodePanel> </go:LinkPanel> </DataTemplate>
-Mike Gold

I have no idea. Usually if there’s a problem, it’s in Silverlight.

I assume you have made sure that the value of your link data property LineThickness is a small positive number.

I suppose you could try simplifying until it starts working again.

I should have looked closer at the documentation

There is a difference betweent the way the Path is done in WPF on a link vs. how it is done in Silverlight. Path's use a regular old Path element in Silverlight with an attached property (go:LinkPanel.IsLinkShape = true)
WPF just uses a new element called <go:LinkShape.
I'd forgotten about it because I never thought I'd be doing the same project in WPF :-)

Sorry about that – that’s another gotcha difference between Silverlight and WPF.

In GoSilverlight 1.2 for Silverlight 4 we have added a LinkShape class for compatibility with WPF. However, there’s still a difference: in Silverlight that LinkShape element still has to be a child of a LinkPanel unless it’s the only element in the Link DataTemplate. But since LinkShape isn’t useful outside of a LinkPanel, there’s no loss.

There’s a similar situation with NodeShape. In Silverlight 4 the new Shape class NodeShape must be a child element of a NodePanel; that restriction does not exist in WPF.

Silverlight 3 did not let us define any subclasses of Shape.