<Button x:Name="RemoveSelectButton" Margin="2" Command="{Binding Select}" CommandParameter="Remove" >
if(editor.Select.CanExecute("Remove")) editor.Select.Execute("Remove");
private void Editor_EditCompleted(object sender, Editor.EditEventArgs e) { System.Diagnostics.Debug.WriteLine(e.Action); foreach (var edit in e.Edits) { if (edit.Graphic.Selected) System.Diagnostics.Debug.WriteLine("{0}-{1}", edit.Graphic.Attributes["ObjectID"], edit.Layer.ID); } }
if(_editor.DeleteSelected.CanExecute(null)) _editor.DeleteSelected.Execute(null);
private void MyEditor_EditCompleted(object sender, Editor.EditEventArgs e) { if (e.Action == Editor.EditAction.DeleteSelected) { foreach (var edit in e.Edits) { //deleted graphic is edit.Graphic //TODO: use edit.Layer } } }
Kindly check your DrawToolsViewModel.cs SetTool() method. This method whenever called subscribes to Editor.EditCompleted. This is the reason you get Select and Cancel action for every graphic that was added.What you can do is use a read-only DrawEditor property with _drawEditor initially set to null. This will ensure that you set Editor properties and subscribe to EditCompleted events once. Instead of using _drawEditor to activate Select/Cancel/EditVertices, use DrawEditor instead.private Editor DrawEditor{get{if (_drawEditor == null){_drawEditor = new Editor();_drawEditor.LayerIDs = new List { DrawToolsGraphicsLayer.ID };_drawEditor.GeometryServiceUrl = "http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer";_drawEditor.ContinuousMode = true;_drawEditor.EditCompleted += new EventHandler(_drawEditor_EditCompleted);}return _drawEditor;}}
if (_drawEditor.LayerIDs == null) { _drawEditor.LayerIDs = new List<string> { DrawToolsGraphicsLayer.ID }; _drawEditor.GeometryServiceUrl = "http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer"; _drawEditor.ContinuousMode = true; _drawEditor.SelectionMode = DrawMode.Point; _drawEditor.EditCompleted += new EventHandler<Editor.EditEventArgs>(_drawEditor_EditCompleted); }
private Editor DrawEditor { get { if (_drawEditor == null) { _drawEditor = new Editor(); _drawEditor.LayerIDs = new List<string> { DrawToolsGraphicsLayer.ID }; _drawEditor.GeometryServiceUrl = "http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer"; _drawEditor.ContinuousMode = true; _drawEditor.EditCompleted += new EventHandler<Editor.EditEventArgs>(_drawEditor_EditCompleted); } return _drawEditor; } }
private void Editor_EditCompleted(object sender, ESRI.ArcGIS.Client.Editor.EditEventArgs e) { System.Diagnostics.Debug.WriteLine(e.Action); foreach (var edit in e.Edits) System.Diagnostics.Debug.WriteLine("id '{0}', layer '{1}'", edit.Graphic.Attributes["objectid"], edit.Layer.ID); }
FeatureLayer layer = edit.Layer as FeatureLayer;
<StackPanel DataContext="{StaticResource MyEditor}" VerticalAlignment="Top" HorizontalAlignment="Center" Orientation="Horizontal"> <Button Content="Select" Command="{Binding Select}" /> <Button Content="Delete" Command="{Binding DeleteSelected}" /> </StackPanel>
xmlns:esri="http://schemas.esri.com/arcgis/client/2009"> <Grid x:Name="LayoutRoot" Background="White" > <Grid.Resources> <esri:Editor x:Key="MyEditor" EditCompleted="Editor_EditCompleted" Map="{Binding ElementName=MyMap}"/> </Grid.Resources> <esri:Map x:Name="MyMap" Extent="-63043237.1870117,-29260415.7409668,36029344.3774414,36661048.8306274"> <esri:FeatureLayer ID="Point" Url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/HomelandSecurity/operations/FeatureServer/0" /> <esri:FeatureLayer ID="Line" Url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/HomelandSecurity/operations/FeatureServer/1"/> <esri:FeatureLayer ID="Area" Url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/HomelandSecurity/operations/FeatureServer/2"/> </esri:Map> <Button DataContext="{StaticResource MyEditor}" Content="Select" Command="{Binding Select}" VerticalAlignment="Top" HorizontalAlignment="Center"/> </Grid>
private void Editor_EditCompleted(object sender, ESRI.ArcGIS.Client.Editor.EditEventArgs e) { System.Diagnostics.Debug.WriteLine(e.Action); }
private void Editor_EditCompleted(object sender, Editor.EditEventArgs e) { if (e.Action == Editor.EditAction.Select) foreach (var edit in e.Edits) System.Diagnostics.Debug.WriteLine(edit.Layer.ID); }
サインインしたメンバーは投稿、更新のフォローなどができます。初めてですか?無料アカウントを登録してください。
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.