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

How to display a contextmenu on rightclick

1 Answer 153 Views
Map
This is a migrated thread and some comments may be shown as answers.
Sumith Jayasuriya
Top achievements
Rank 1
Sumith Jayasuriya asked on 15 Jul 2011, 10:38 PM
Is contextmenu enabled for RadMap for Silverlight?  If YES which version of RadControls?

 If NO, is there an alternative way to handle right mouse click and display a menu?

Thanks
Sumith

1 Answer, 1 is accepted

Sort by
0
Accepted
Andrey
Telerik team
answered on 20 Jul 2011, 01:43 PM
Hello Sumith,

Yes, RadContextMenu can be used now with RadMap for Silverlight. You may try it with our latest Q2 2011 binaries - 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!

Tags
Map
Asked by
Sumith Jayasuriya
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Share this question
or