I am having an interesting problem when trying to commit an edit I just performed on a polygon graphic. The only way I know of to commit an edit to a graphic is to click on the graphic that was just edited or another graphic in the map (as long as it's not a point?!?). This works fine as long as the initial edit on that graphic was initiated by a click on the graphic when the editor is placed into EditVertices mode with the following command:Editor.EditVertices.Execute(null);If I try to use that same command to place a specific graphic into edit mode automatically, the commit stuff starts to get whacked out. Here's the command I use:Editor.EditVertices.Execute([graphic object]);That puts the edit handles on the polygon just fine. So then I can move that graphic to a new location, but when I click on it to commit the edit the polygon goes back to its original location. When I click on it again it moves back to the location it was at after the first move. Weird behavior, no? So this seems like a bug, but I wanted to see if anyone else has experienced a similar issue and knows how to get around it. This is obviously not desired behavior. I am including my stripped down XAML and C# code so the problem can be recreated. Here are the steps to recreate:1) Click the Add Poly button and draw a polygon on the map2) Click the Edit Vertices button to place that polygon into edit mode3) Move the polygon to a new location4) Click it to commit the edit. The polygon should move back to where it was originally.5) Click it again. The polygon should now move back to where you first moved it.Thanks in advance for any help with this.Here's the XAML code:
<UserControl x:Class="ESRIEditingTest.MainPage"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:esri="http://schemas.esri.com/arcgis/client/2009">
<Grid x:Name="LayoutRoot">
<Grid.Resources>
<esri:Editor x:Name="MyEditor" ContinuousMode="True"
Map="{Binding ElementName=MyMap}"
LayerIDs="Graphics"
GeometryServiceUrl="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer" />
</Grid.Resources>
<esri:Map x:Name="MyMap" Extent="-13054165,3850112,-13027133,3863559" esri:Editor.SnapDistance="20" esri:Editor.SnapKey="S">
<esri:ArcGISTiledMapServiceLayer ID="BaseLayer" Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer" />
<esri:GraphicsLayer ID="Graphics" />
</esri:Map>
<Border Background="#FF919191" BorderThickness="1" CornerRadius="5"
HorizontalAlignment="Right" VerticalAlignment="Top"
Padding="5" BorderBrush="Black" Margin="0,5,5,0"
DataContext="{StaticResource MyEditor}">
<StackPanel x:Name="EditorTools" Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<Button x:Name="AddPolyButton" Margin="2" Click="AddPolyButton_Click">
<TextBlock>Add Poly</TextBlock>
</Button>
<Button x:Name="EditVertices" Margin="2" Click="EditVerticesButton_Click">
<TextBlock>Edit Vertices</TextBlock>
</Button>
<Button x:Name="ClearGRaphics" Margin="2" Click="ClearGraphicsButton_Click">
<TextBlock>Clear Graphics</TextBlock>
</Button>
</StackPanel>
</StackPanel>
</Border>
</Grid>
</UserControl>
Here's the C# code:
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using ESRI.ArcGIS.Client;
using ESRI.ArcGIS.Client.Geometry;
using ESRI.ArcGIS.Client.Symbols;
namespace ESRIEditingTest
{
public partial class MainPage : UserControl
{
GraphicsLayer _gl;
private Draw _drawObject = new Draw();
public MainPage()
{
InitializeComponent();
MyMap.Loaded += new RoutedEventHandler(MyMap_Loaded);
}
void MyMap_Loaded(object sender, RoutedEventArgs e)
{
_drawObject.Map = MyMap;
_drawObject.DrawComplete += new EventHandler<DrawEventArgs>(_drawObject_DrawComplete);
_gl = MyMap.Layers["Graphics"] as GraphicsLayer;
}
void _drawObject_DrawComplete(object sender, DrawEventArgs e)
{
Graphic gr = new Graphic();
SimpleFillSymbol sfs = new SimpleFillSymbol();
sfs.Fill = new SolidColorBrush(Colors.Red);
Polygon p = e.Geometry as Polygon;
gr = new Graphic
{
Geometry = p,
Symbol = sfs
};
_gl.Graphics.Add(gr);
_drawObject.IsEnabled = false;
}
private void AddPolyButton_Click(object sender, RoutedEventArgs e)
{
_drawObject.IsEnabled = true;
_drawObject.DrawMode = DrawMode.Polygon;
}
private void EditVerticesButton_Click(object sender, RoutedEventArgs e)
{
_drawObject.IsEnabled = false;
MyEditor.EditVertices.Execute(_gl.Graphics[0]);
}
private void ClearGraphicsButton_Click(object sender, RoutedEventArgs e)
{
_gl.Graphics.Clear();
}
}
}