Link Contextmenu

I’ve added a simple contextmenu to my link template.

It works fine on a right-click ONLY if the link is not first selected.
If I select the link (by left-clicking on it to highlight it) I get the default Silverlight menu when I right-click. My custom contextmenu is not presented.
If I click off the link (to un-highlight it) and then right click on it (again, without first selecting it), my menu is presented as expected.
Is this a known issue or have I done something wrong?
Here's my XAML:

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


For the version 1.3 kit we have added a simple app that includes context menus for nodes, for links, and for the background. This app does not demonstrate the behavior that you are talking about.

Here’s the link template from that “BasicApp”:

[code] <go:BooleanBrushConverter x:Key=“theSelectionConverter”
FalseBrush=“Transparent” TrueBrush=“DodgerBlue” />

<DataTemplate x:Key="MyLinkTemplate">
      <go:Route RelinkableFrom="True" RelinkableTo="True" />
    <go:LinkShape Stroke="{Binding Path=Part.IsSelected, Converter={StaticResource theSelectionConverter}}"
                  StrokeThickness="5" />
    <go:LinkShape x:Name="Path" Stroke="Black" StrokeThickness="1" />
    <Path Fill="Black" go:LinkPanel.ToArrow="Standard" />
        <input:MenuItem Header="a link command" Click="LinkMenuClick" />

And the code-behind:

private void LinkMenuClick(object sender, RoutedEventArgs e) { var elt = sender as FrameworkElement; if (elt != null && elt.DataContext != null) { var data = ((PartManager.PartBinding)elt.DataContext).Data as MyLinkData; MessageBox.Show("Link: " + data.ToString()); } }

Where can I get that BasicApp? I went to the download area but I only see 1.2.

Upon further testing, what happens is the ContextMenu for the background is shown (if there is one) when you right-click a selected/highlighted node.
My original app did not have a background context menu, so I see the Silverlight menu by default.
I can only get the node's contextmenu to appear if the node is not yet selected.

That’s interesting – so there is a problem with context menus in Silverlight when using the standard selection adornment on links.

The reason is that the standard Silverlight mechanisms for dealing with mouse right button events will result in finding the selection adornment of a selected link, because the selection adornment is in front of the link shape. But there’s no context menu declared for that adornment, so it does nothing.

I have modified the example app not to use a selection adornment but to change the color of the thick link shape that is normally transparent. Now it turns blue when the link is selected.