ArcGIS API for WPF - Library Reference
Editor Class
Members  See Also  Send comments on this topic
ESRI.ArcGIS.Client Namespace : Editor Class

Editor object which enables editing and selection support for FeatureLayer and GraphicsLayer.

Object Model

Editor ClassMap Class

Syntax

Visual Basic (Declaration) 
Public Class Editor 
   Inherits System.Windows.DependencyObject
C# 
public class Editor : System.Windows.DependencyObject 

Remarks

The Editor object can be used to perform selection, draw and edit of graphics in a feature layer and graphics layer. The Editor requires the Map property to be set, and optionally a set of LayerIDs to work against, otherwise all GraphicsLayers are active for editing.

Editing is performed by executing an System.Windows.Input.ICommand on the Editor. The following commands are supported by the Editor:

Command Description
Add Allows the user to draw and add a new graphic to a layer.
CancelActive Cancels any active command active on the map.
ClearSelection Unselects all graphics.
Cut Uses a GeometryService to cut graphics with a line drawn by the user.
DeleteSelected Deletes all selected graphics.
EditVertices Edits the vertices of any graphic clicked by the user.
Reshape Uses a GeometryService to reshape selected graphics with a line drawn by the user.
Save Commits any unsaved edits in all FeatureLayers.
Select Allows the user to select graphics.
Union Uses a GeometryService to union selected graphics.

Use the System.Windows.Input.ICommand.CanExecute(System.Object) method to verify if an action can be executed. Based on the current selection and other Editor settings some actions might not be executable. For instance, you cannot perform a union if only one graphic is selected. Selection on a GraphicsLayer is only supported using a point or rectangle, while all selection modes are available on FeatureLayer. If the GeometryServiceUrl is not set, commands that require this service will not be available. A read-only FeatureLayer will only support selection, no editing.

You can have any number of Editors associated with a map. If one Editor's command becomes active, it will cancel any other Editor's currently working on the map. This will prevent the user from adding and selecting features at the same time. Note: Only commands requiring user input will cancel other commands. For example, clicking save will not cancel a draw currently in progress.

Some command takes an additional CommandParameter to control the command. For example Select has an optional parameter to choose whether the user wants to Add or Remove features to the current selection. Similarly Add requires a specific template or type id for drawing on a FeatureLayer, but a ESRI.ArcGIS.Client.Symbols.Symbol for drawing on a GraphicsLayer. See the individual command reference for more detail on command parameters.

Controls can implement their own handling of ICommand. For example, a control can listen to the System.Windows.Input.ICommand.CanExecuteChanged event and change its enable or visibility state. System.Windows.Controls.Primitives.ButtonBase and Hyperlink already implement commanding and will change their IsEnabled state based on whether the command can execute. As a result, the developer does not have to update the button state explicity when the Editor or a layer changes.

The following example shows how to create a select tool using an editor:
            <Border>
              <Border.Resources>
                <esri:Editor x:Key="editor" Map="{Binding ElementName=MyMap}" LayerIDs="myFeatureLayer"  />
              </Border.Resources>
              <StackPanel Orientation="Horizontal" DataContext="{StaticResource editor}">
                <Button Content="Select" Command="{Binding Select}" CommandParameter="New" />
                <Button Content="Add Selection" Command="{Binding Select}" CommandParameter="Add" />
                <Button Content="Unselect" Command="{Binding Select}" CommandParameter="Remove" />
                <Button Content="Clear Selection" Command="{Binding ClearSelection}" />
                <Button Content="Add Default" Command="{Binding Add}" />
                <Button Content="Add MyFeatureType" Command="{Binding Add}" CommandParameter="MyFeatureTemplate" />
                <Button Content="Delete Selected" Command="{Binding DeleteSelected}" />
                <CheckBox IsChecked="{Binding Path=Freehand, Mode=TwoWay}" Content="Freehand Draw" VerticalAlignment="Center" />
              </StackPanel>
            </Border>
            

To see a visual change to a ESRI.ArcGIS.Client.Symbols.Symbol when its selected, it must have a Selected state defined. The simple symbols included with the ArcGIS API for Silverlight/WPF do not include a selected state. However symbols created using definitions provided by an ArcGIS Server REST feature service will include a selected state.

Whenever an action completes, the Editor.EditCompleted event is fired. Use the Editor.ActionEventArgs.Action to perform additional logic when an operation completes.

The Editor is able to work on multiple layers at the same time. Be aware of using AutoSelect on some of the commands like union and reshape when working with multiple layers. The AutoSelect feature may cause the user to edit features in layers they didn't intend to (note that union won't union features across layers, but will union features together within it). A good approach to avoid this issue, is using a System.Windows.Controls.ComboBox to select the layer the user wants to perform edits on, and set the LayerIDs property when the user selects a layer in the ComboBox.

Inheritance Hierarchy

System.Object
   System.Windows.Threading.DispatcherObject
      System.Windows.DependencyObject
         ESRI.ArcGIS.Client.Editor

Requirements

Target Platforms: Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family

See Also

© ESRI, Inc. All Rights Reserved.