I made a modified version of the WPF sample. I added an event handler for a right click that completes the current sketch and starts a new one. You can start drawing the next shape without moving the map.
Please share more of your code so I can understand your issue better.
Zack
using Esri.ArcGISRuntime.Data;
using Esri.ArcGISRuntime.Geometry;
using Esri.ArcGISRuntime.Mapping;
using Esri.ArcGISRuntime.Symbology;
using Esri.ArcGISRuntime.UI;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using Point = System.Windows.Point;
namespace ArcGISRuntime.WPF.Samples.SketchOnMap
{
[ArcGISRuntime.Samples.Shared.Attributes.Sample(
name: "Sketch on map",
category: "GraphicsOverlay",
description: "Use the Sketch Editor to edit or sketch a new point, line, or polygon geometry on to a map.",
instructions: "Choose which geometry type to sketch from one of the available buttons. Choose from points, multipoints, polylines, polygons, freehand polylines, and freehand polygons.",
tags: new[] { "draw", "edit" })]
public partial class SketchOnMap
{
private GraphicsOverlay _sketchOverlay;
public SketchOnMap()
{
InitializeComponent();
Initialize();
}
private void Initialize()
{
Map myMap = new Map(Basemap.CreateLightGrayCanvas());
_sketchOverlay = new GraphicsOverlay();
MyMapView.GraphicsOverlays.Add(_sketchOverlay);
MyMapView.Map = myMap;
SketchModeComboBox.ItemsSource = System.Enum.GetValues(typeof(SketchCreationMode));
SketchModeComboBox.SelectedIndex = 0;
DataContext = MyMapView.SketchEditor;
}
#region Graphic and symbol helpers
private Graphic CreateGraphic(Esri.ArcGISRuntime.Geometry.Geometry geometry)
{
Symbol symbol = null;
switch (geometry.GeometryType)
{
case GeometryType.Envelope:
case GeometryType.Polygon:
{
symbol = new SimpleFillSymbol()
{
Color = Color.Red,
Style = SimpleFillSymbolStyle.Solid
};
break;
}
case GeometryType.Polyline:
{
symbol = new SimpleLineSymbol()
{
Color = Color.Red,
Style = SimpleLineSymbolStyle.Solid,
Width = 5d
};
break;
}
case GeometryType.Point:
case GeometryType.Multipoint:
{
symbol = new SimpleMarkerSymbol()
{
Color = Color.Red,
Style = SimpleMarkerSymbolStyle.Circle,
Size = 15d
};
break;
}
}
return new Graphic(geometry, symbol);
}
private async Task<Graphic> GetGraphicAsync()
{
Geometry mapPoint = await MyMapView.SketchEditor.StartAsync(SketchCreationMode.Point, false);
Point screenCoordinate = MyMapView.LocationToScreen((MapPoint)mapPoint);
IReadOnlyList<IdentifyGraphicsOverlayResult> results = await MyMapView.IdentifyGraphicsOverlaysAsync(screenCoordinate, 2, false);
Graphic graphic = null;
IdentifyGraphicsOverlayResult idResult = results.FirstOrDefault();
if (idResult != null && idResult.Graphics.Count > 0)
{
graphic = idResult.Graphics.FirstOrDefault();
}
return graphic;
}
#endregion Graphic and symbol helpers
private void DrawButtonClick(object sender, RoutedEventArgs e)
{
Draw();
}
private async void Draw()
{
try
{
SketchCreationMode creationMode = (SketchCreationMode)SketchModeComboBox.SelectedItem;
Esri.ArcGISRuntime.Geometry.Geometry geometry = await MyMapView.SketchEditor.StartAsync(creationMode, true);
Graphic graphic = CreateGraphic(geometry);
_sketchOverlay.Graphics.Add(graphic);
ClearButton.IsEnabled = _sketchOverlay.Graphics.Count > 0;
EditButton.IsEnabled = _sketchOverlay.Graphics.Count > 0;
}
catch (TaskCanceledException)
{
}
catch (Exception ex)
{
MessageBox.Show("Error drawing graphic shape: " + ex.Message);
}
}
private void ClearButtonClick(object sender, RoutedEventArgs e)
{
_sketchOverlay.Graphics.Clear();
ClearButton.IsEnabled = false;
EditButton.IsEnabled = false;
}
private async void EditButtonClick(object sender, RoutedEventArgs e)
{
try
{
Graphic editGraphic = await GetGraphicAsync();
if (editGraphic == null) { return; }
Esri.ArcGISRuntime.Geometry.Geometry newGeometry = await MyMapView.SketchEditor.StartAsync(editGraphic.Geometry);
editGraphic.Geometry = newGeometry;
}
catch (TaskCanceledException)
{
}
catch (Exception ex)
{
MessageBox.Show("Error editing shape: " + ex.Message);
}
}
private void MyMapView_MouseRightButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
if(MyMapView.SketchEditor.CompleteCommand.CanExecute(null))
{
MyMapView.SketchEditor.CompleteCommand.Execute(null);
e.Handled = true;
Draw();
}
}
}
}
<UserControl
x:Class="ArcGISRuntime.WPF.Samples.SketchOnMap.SketchOnMap"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DesignHeight="500"
d:DesignWidth="600"
mc:Ignorable="d">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="300" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<esri:MapView
x:Name="MyMapView"
Grid.Column="1"
MouseRightButtonUp="MyMapView_MouseRightButtonUp" />
<Grid Grid.Column="0">
<Grid.RowDefinitions>
<RowDefinition Height="50" />
<RowDefinition Height="35" />
<RowDefinition Height="35" />
<RowDefinition Height="35" />
<RowDefinition Height="20" />
<RowDefinition Height="35" />
<RowDefinition Height="35" />
<RowDefinition Height="20" />
<RowDefinition Height="35" />
<RowDefinition Height="35" />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<TextBlock
Grid.Row="1"
Grid.Column="0"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Text="Sketch shape:" />
<ComboBox
x:Name="SketchModeComboBox"
Grid.Row="1"
Grid.Column="1"
Margin="5"
HorizontalAlignment="Stretch"
VerticalAlignment="Center" />
<Button
Grid.Row="2"
Grid.Column="1"
Width="100"
Height="25"
Margin="5"
HorizontalAlignment="Center"
VerticalAlignment="Top"
Click="DrawButtonClick"
Content="Draw" />
<Button
x:Name="EditButton"
Grid.Row="3"
Grid.Column="1"
Width="100"
Height="25"
Margin="5"
HorizontalAlignment="Center"
VerticalAlignment="Top"
Click="EditButtonClick"
Content="Edit"
IsEnabled="False" />
<StackPanel
Grid.Row="5"
Grid.Column="1"
HorizontalAlignment="Center"
VerticalAlignment="Top"
Orientation="Horizontal">
<Button
Width="50"
Height="25"
Margin="5"
Command="{Binding UndoCommand}"
Content="Undo" />
<Button
Width="50"
Height="25"
Margin="5"
Command="{Binding RedoCommand}"
Content="Redo" />
</StackPanel>
<Button
Grid.Row="6"
Grid.Column="1"
Width="100"
Height="25"
Margin="5"
HorizontalAlignment="Center"
VerticalAlignment="Top"
Command="{Binding CompleteCommand}"
Content="Complete" />
<Button
Grid.Row="8"
Grid.Column="1"
Width="100"
Height="25"
Margin="5"
HorizontalAlignment="Center"
VerticalAlignment="Top"
Command="{Binding CancelCommand}"
Content="Cancel" />
<Button
x:Name="ClearButton"
Grid.Row="9"
Grid.Column="1"
Width="100"
Height="25"
Margin="5"
HorizontalAlignment="Center"
VerticalAlignment="Top"
Click="ClearButtonClick"
Content="Clear"
IsEnabled="False" />
</Grid>
</Grid>
</UserControl>