Got pointed in the right direction from Antti Kajanus on the ESRI forum. Here is the relevant Drop method:
private void Drop(object e)
{
var args = e as DragEventArgs;
if (args == null)
return;
var mousePosition = args.GetPosition(_map);
var mapPoint = _map.ScreenToMap(mousePosition);
if (_map.WrapAroundIsActive)
mapPoint = Geometry.NormalizeCentralMeridian(mapPoint) as MapPoint;
var graphic = new Graphic();
graphic .Geometry = mapPoint;
MyLayer.Graphics.Add(graphic );
}
I have posted a complete sample application at https://github.com/keithgemeinhart/ArcGis.Wpf.DragDropDemo
A couple of key points ....
I use the GalaSoft MVVM Light library to get an implementation of EventToCommand. The provides a mechanism for mapping an event to a command in the view model. For example:
<i:Interaction.Triggers >
<i:EventTrigger EventName="Loaded">
<cmd:EventToCommand Command="{Binding MapLoadedCommand, Source={StaticResource DragDropViewModel}}" PassEventArgsToCommand="True"/>
</i:EventTrigger>
</i:Interaction.Triggers>
This maps the Loaded event on the map to the MapLoadedCommand in the DragDropViewModel. That's a key event because we need a means for getting a map reference into the view model. So my solution was to capture the map reference as a parameter of the map's Loaded event. Here is the implementation in the view model. The last line in the method extracts the map reference from the RoutedEventArgs Source property.
private void MapLoaded(object parameter)
{
// See if the event sent the map in the event args
var p1 = parameter as System.Windows.RoutedEventArgs;
if (p1 == null)
{
throw new NullReferenceException("Cannot capture map reference.");
return;
}
_map = p1.Source as Map;
}