I'm trying to add a context menu to markers however, on right click nothing appears... I've tried multiple ways, could anyone suggest the problem?
Here are the different ways I've tried:
1:
Marker marker = new Marker(location.X, location.Y);
ContextMenu markerContextMenu = new ContextMenu();
MenuItem removeMenuItem = new MenuItem();
removeMenuItem.Header = "Remove Placemark";
removeMenuItem.Click += OnRemove_Click;
markerContextMenu.Items.Add(removeMenuItem);
marker.ContextMenu = markerContextMenu;
2:
Marker marker = new Marker(location.X, location.Y);
ContextMenu markerContextMenu = new ContextMenu();
MenuItem removeMenuItem = new MenuItem();
removeMenuItem.Header = "Remove Placemark";
removeMenuItem.Click += OnRemove_Click;
markerContextMenu.Items.Add(removeMenuItem);
marker.SetResourceReference(Marker.ContextMenuProperty, markerContextMenu);
3:
DataTemplate markerTemplate = (DataTemplate) FindResource("MarkerTemplate");
Marker marker = new Marker(sensorLocation.X, sensorLocation.Y);
marker.ContentTemplate = markerTemplate;
<DataTemplate x:Key="MarkerTemplate">
<map:Marker Content="{Binding Path=Name}">
<map:Marker.ContextMenu>
<ContextMenu>
<MenuItem Header="Remove Placemark" Click="OnRemove_Click"/>
</ContextMenu>
<map:Marker.ContextMenu>
</map:Marker>
</DataTemplate>
None have worked so far... How do I use context menus on a marker?