This is a migrated thread and some comments may be shown as answers.

Adding a right-click context menu to a push-pin

1 Answer 26 Views
Map
This is a migrated thread and some comments may be shown as answers.
Derek
Top achievements
Rank 1
Derek asked on 20 Dec 2013, 08:35 PM
Hello,

I would like to programatically generate a RadContextMenu when push-pins on my RadMap are right-clicked.

Currently I have an event  added to my "ClusteredItemTemplate" that points to my method "ClustereItemRightClick"
<DataTemplate x:Key="ClusteredItemTemplate">
            <telerik:Pushpin telerik:MapLayer.Location="{Binding Path=Location}" Style="{StaticResource CustomPushpin}"
                             ToolTipService.ToolTip="{Binding Title}"
                             ToolTipService.Placement="Mouse"
                             MouseLeftButtonUp="ClusteredItemMouseClick"
                             MouseRightButtonUp="ClusteredItemRightClick">
            </telerik:Pushpin>
</DataTemplate>

private void ClusteredItemRightClick(Pushpin sender, MouseEventArgs e)
        {
            RadContextMenu contextMenu = new RadContextMenu();
            contextMenu.Items.Add(new RadMenuItem() { Header = "Go to building view" });
            contextMenu.PlacementTarget = sender;
            contextMenu.IsOpen = true;
        }

At runtime I get the error "Failed to assign to property 'System.Windows.UIElement.MouseRightButtonUp'."
Any ideas on how to generate RadContextMenus for Pushpins?

Thanks.

1 Answer, 1 is accepted

Sort by
0
Petar Marchev
Telerik team
answered on 25 Dec 2013, 03:10 PM
Hi Derek,

I think that you are getting the exception only because the signature of the event handler is incorrect:
// private void ClusteredItemRightClick(Pushpin sender, MouseEventArgs e) // incorrect
private void ClusteredItemRightClick(object sender, MouseButtonEventArgs e) // correct

Do try this and see how it goes.

Regards,
Petar Marchev
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
Map
Asked by
Derek
Top achievements
Rank 1
Answers by
Petar Marchev
Telerik team
Share this question
or