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

2 posts, 0 answers
  1. Derek
    Derek avatar
    2 posts
    Member since:
    Jun 2013

    Posted 20 Dec 2013 Link to this post

    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.
  2. Petar Marchev
    Admin
    Petar Marchev avatar
    968 posts

    Posted 25 Dec 2013 Link to this post

    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 >>
  3. DevCraft banner
Back to Top