You can use SketchEditor for this. Point geometry is updated either by tapping a new location or by dragging the graphic. StartAsync will return new geometry once you call Complete command. You can use Complete button or subscribe to GeometryChanged and let the handler execute CompleteCommand programmatically to get new geometry on mouse up.
xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013">
<Grid>
<esri:MapView x:Name="MyMapView" />
<StackPanel VerticalAlignment="Top"
HorizontalAlignment="Right">
<Button Content="Edit"
Click="Button_Click" />
<Button Content="Complete"
Command="{Binding ElementName=MyMapView, Path=SketchEditor.CompleteCommand}" />
</StackPanel>
</Grid>
In this sample code, I am using SketchEditor for two purposes:
1) to identify and select graphic for edit
2) to update graphic geometry
Handle TaskCanceledException in case "Edit" button was clicked again, which will cancel previous StartAsync call.
public MainWindow()
{
InitializeComponent();
MyMapView.Map = new Map(Basemap.CreateTopographic());
var overlay = new GraphicsOverlay() { RenderingMode = GraphicsRenderingMode.Static };
overlay.Renderer = new SimpleRenderer(new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, Colors.Blue, 12d));
overlay.Graphics.Add(new Graphic(new MapPoint(0, 0, MyMapView.SpatialReference)));
MyMapView.GraphicsOverlays.Add(overlay);
}
private async void Button_Click(object sender, RoutedEventArgs e)
{
Graphic graphic = null;
try
{
foreach (var overlay in MyMapView.GraphicsOverlays)
overlay.ClearSelection();
var mapPoint = await MyMapView.SketchEditor.StartAsync(SketchCreationMode.Point, false) as MapPoint;
var screenPoint = MyMapView.LocationToScreen(mapPoint);
var results = await MyMapView.IdentifyGraphicsOverlaysAsync(screenPoint, 1, false, 1);
var result = results?.FirstOrDefault();
graphic = result?.Graphics?.FirstOrDefault();
if (graphic == null)
return;
graphic.IsSelected = true;
graphic.IsVisible = false;
var geometry = await MyMapView.SketchEditor.StartAsync(graphic.Geometry);
graphic.Geometry = geometry;
}
catch (TaskCanceledException)
{
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
if (graphic != null)
graphic.IsVisible = true;
}
}
private void SketchEditor_GeometryChanged(object sender, GeometryChangedEventArgs e)
{
if (MyMapView.SketchEditor.CompleteCommand.CanExecute(null))
MyMapView.SketchEditor.CompleteCommand.Execute(null);
}