Double Click on Link Path

Hi Walter,

I'm having trouble getting double click to work on the path of a link. It works great on the label and the arrows, but not on the path. It does seem to receive the first mousedown, but not after that. Here is the code I used on the path itself. It never gets into the IsDoubleClick method condition.
** (Also I notice that if I turned Part.Selectable to False) it works, so I suspect it has to do with the selection of the link)***
private void Path_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e){ if (DiagramPanel.IsDoubleClick(e)) { var link = Part.FindAncestor<Link>(sender as UIElement); if (link != null && link .Data != null) { e.Handled = true; (link.Data as LatLinkModel).DoubleClickCommand.Execute(null); } } }

I just tried your code, but replacing your call to “Execute” with generating a trace message. I also declared the event handler as follows:


<Path-or-go:LinkShape … MouseLeftButtonDown=“Path_MouseLeftButtonDown” />

Everything worked fine, as one would expect. I tried this in both Silverlight 4 and in WPF 4.

So I’m curious what’s different about your situation.

Is there a reason you are declaring the event handler on the Path or go:LinkShape instead of on the root element of the link’s DataTemplate?

Might the link be thin, and the second click is happening “off” of the link shape, thereby never resulting in a second call to the event handler?

It has to do with Part.Selectable, because if Part.Selectable is false it works fine (even on single pixel paths ). I did try it on the LinkPanel itself in the data template and got the same result.

<go:LinkPanel go:Part.SelectionElementName="Path" go:Part.SelectionAdorned="True" go:Part.Selectable="True" go:Part.LayerName="Background" > <go:Link.Route> <go:Route Routing="{Binding Data.Routing}" Curve="{Binding Data.Curve}" Corner="10" /> </go:Link.Route> <Path go:LinkPanel.IsLinkShape="True" x:Name="Path" StrokeThickness="1" MouseLeftButtonDown="Path_MouseLeftButtonDown" >

The Links I tested before were Selectable.

This time I have simply modified the FlowChart sample.

Here’s the updated Link DataTemplate:

<DataTemplate x:Key="LinkTemplate"> <go:LinkPanel go:Part.Reshapable="True"> <go:Link.Route> <go:Route Routing="AvoidsNodes" Curve="JumpOver" Curviness="10" RelinkableFrom="True" RelinkableTo="True" /> </go:Link.Route> <Path Fill="Black" go:LinkPanel.ToArrow="Standard" /> <Path go:LinkPanel.IsLinkShape="True" Stroke="Black" StrokeThickness="2" <font color="#ff0000">MouseLeftButtonDown="LinkShape_MouseLeftButtonDown"</font> /> <!-- this is the label that is only shown when connected to a Decision node --> <TextBlock Text="{Binding Path=Data.Text, Mode=TwoWay}" TextWrapping="Wrap" MaxWidth="50" go:Part.TextEditable="True" go:LinkPanel.Index="1" go:LinkPanel.Alignment="0 0 -2 0" Visibility="{Binding Path=Link, Converter={StaticResource theLabelVisibilityConverter}}" /> </go:LinkPanel> </DataTemplate>
Here’s the event handler:

private void LinkShape_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { if (DiagramPanel.IsDoubleClick(e)) { var link = Part.FindAncestor<Link>(sender as UIElement); if (link != null && link.Data != null) { e.Handled = true; System.Diagnostics.Debug.WriteLine("LinkShape_MouseLeftButtonDown " + link.ToString()); } } }
Double-click is working as expected for me. This is in v1.2, using Silverlight 3.