rightclick on shape

5 posts, 1 answers
  1. Tamas
    Tamas avatar
    33 posts
    Member since:
    Jun 2010

    Posted 05 Dec 2010 Link to this post

    Hi,

    I tried to add an event handler to each shape displayed on my map. However only the usual Silverlight context menu pops up. I have the following code:

    foreach(MapShape shape in eventArgs.Items)
    {
        shape.MouseLeftButtonUp += this.ShapeMouseLeftButtonUp;
        shape.MouseRightButtonUp += this.ShapeMouseRightButtonUp;
    }

    The left click works fine. Do I have to do something extra to execute my event handler?

    Thanks and best regards,
    Tamas
  2. Answer
    Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 08 Dec 2010 Link to this post

    Hello Tamas,

    Unfortunately current version of the RadMap doesn't support right button events on the map shape objects. We have this functionality in our plans. You can check its availability using PITS:

    http://www.telerik.com/support/pits.aspx#/public/silverlight/4270

    We are planning include this feature into the upcoming service pack.

    Best wishes,
    Andrey Murzov
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
  3. DevCraft banner
  4. Tamas
    Tamas avatar
    33 posts
    Member since:
    Jun 2010

    Posted 08 Dec 2010 Link to this post

    Hi Andrey,

    Thanks for your help!

    Best regards,
    Tamas
  5. Sumith Jayasuriya
    Sumith Jayasuriya avatar
    25 posts
    Member since:
    Jan 2010

    Posted 13 Jul 2011 Link to this post

    When I check PITS the isue is flagged as resolved.  Is the ContextMenu now available for RadMap for Silverlight?

    Thanks
    Sumith
  6. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 18 Jul 2011 Link to this post

    Hello Sumith,

    Yes, RadContextMenu can be used now with RadMap for Silverlight. For example:
    <UserControl x:Class="DetectShapeAtLocation.MainPage"
         mc:Ignorable="d"
         d:DesignHeight="400" d:DesignWidth="400">
        <Grid x:Name="LayoutRoot" Background="White">
            <telerik:RadMap x:Name="RadMap1"
                    Center="56.1260873546439,10.1076291138805"
                    ZoomLevel="3"
                    MouseRightButtonDown="MapMouseRightButtonDown"
                    MouseRightButtonUp="MapMouseRightButtonUp">
                <telerik:RadMap.Provider>
                    <telerik:OpenStreetMapProvider />
                </telerik:RadMap.Provider>
                <telerik:RadContextMenu.ContextMenu>
                    <telerik:RadContextMenu>
                        <telerik:RadMenuItem Header="Menu 1" Click="MenuItemClicked" />
                    </telerik:RadContextMenu>
                </telerik:RadContextMenu.ContextMenu>
            </telerik:RadMap>
        </Grid>
    </UserControl>


    private Location menuLocation = Location.Empty;
     
    private void MenuItemClicked(object sender, Telerik.Windows.RadRoutedEventArgs e)
    {
        if (!this.menuLocation.IsEmpty)
        {
            // Perform operation
        }
    }
     
    private void MapMouseRightButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
    {
        e.Handled = true;
    }
     
    private void MapMouseRightButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
    {
        this.menuLocation = Location.GetCoordinates(this.RadMap1, e.GetPosition(this.RadMap1));
    }

    Best wishes,
    Andrey Murzov
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Back to Top
DevCraft banner