Edit Tools - Explicit Save

This sample demonstrates using the ESRI.ArcGIS.Client Editor on an ArcGISLocalFeatureLayer where the edit changes are saved explicitly by the person editing the maps features.

Individual Editor functions like: Save, Add, Select, ClearSelection, EditVerticies, etc. are bound to Buttons using the Command property. Additional Editor functions like: Freehand, AutoComplete, AutoSelect, and ContinuousMode are bound to CheckBoxes using the IsChecked property. The 'Cancel Edits' has code-behind logic to undo any graphic added to the map up to the last save that was issued.

To use the sample, use the Add Polygon button to draw a polygon on the map. Use other buttons to move, modify, select or delete features. Use the Save Edits button to commit edits to the database. Cancel Edits will clear all edits up to that point.

Download Sample Application
XAML C# VB.NET
<UserControl x:Class="ArcGISWPFSDK.LocalEditToolsExplicitSave"
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
     xmlns:esri="http://schemas.esri.com/arcgis/client/2009"
     xmlns:sys="clr-namespace:System;assembly=mscorlib">
    <Grid x:Name="LayoutRoot">
        <Grid.Resources>
            <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
            <esri:Editor x:Key="MyEditor"                          
                         LayerIDs="States"                      
                             />
            <LinearGradientBrush x:Key="PanelGradient" EndPoint="0.5,1" StartPoint="0.5,0">
                <LinearGradientBrush.RelativeTransform>
                    <TransformGroup>
                        <ScaleTransform CenterY="0.5" CenterX="0.5"/>
                        <SkewTransform CenterY="0.5" CenterX="0.5"/>
                        <RotateTransform Angle="176" CenterY="0.5" CenterX="0.5"/>
                        <TranslateTransform/>
                    </TransformGroup>
                </LinearGradientBrush.RelativeTransform>
                <GradientStop Color="#FF145787"/>
                <GradientStop Color="#FF3D7FAC" Offset="0.184"/>
                <GradientStop Color="#FF88C5EF" Offset="0.984"/>
            </LinearGradientBrush>
        </Grid.Resources>
        <esri:Map x:Name="MyMap" Extent="-15000000,2000000,-7000000,8000000" Background="#FFE3E3E3" WrapAround="True" esri:Editor.SnapDistance="20" esri:Editor.SnapKey="S" MinimumResolution="2445.98490512499">
            <esri:ArcGISLocalTiledLayer ID="BaseMap" Path="..\\Data\\TPKs\\Topographic.tpk"/>
            <esri:ArcGISLocalFeatureLayer ID="States" LayerName="States" 
                   Path="..\\Data\\MPKS\\USCitiesStatesEdit.mpk"  DisableClientCaching="True"  Editable="True"
                                AutoSave="False"  ValidateEdits="True" Mode="OnDemand"  SelectionColor="#FFFFFF00" PropertyChanged="LocalFeatureLayer_PropertyChanged"                  
                    OutFields="STATE_NAME,POP2000"/>
        </esri:Map>
        <Border Background="{StaticResource PanelGradient}" 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="AddButton" Margin="2"
                         ToolTipService.ToolTip="Fire"
                         Content="Add Polygon" 
                         Click="AddButton_Click" IsEnabled="False">
                    </Button>
                    <Button x:Name="SelectButton" Margin="2"                            
                            Command="{Binding Select}" 
                            CommandParameter="New" >
                        <TextBlock>New<LineBreak/>Selection</TextBlock>
                    </Button>
                    <Button x:Name="AddSelectButton" Margin="2"                            
                            Command="{Binding Select}" 
                            CommandParameter="Add">
                        <TextBlock>Add to<LineBreak/>Selection</TextBlock>
                    </Button>
                    <Button x:Name="RemoveSelectButton" Margin="2"                             
                            Command="{Binding Select}"
                            CommandParameter="Remove" >
                        <TextBlock>Remove from<LineBreak/>Selection</TextBlock>
                    </Button>
                    <Button x:Name="ClearSelectionButton" Margin="2"                            
                            Command="{Binding ClearSelection}">
                        <TextBlock>Clear<LineBreak/>Selection</TextBlock>
                    </Button>
                    <Button x:Name="DeleteButton" Margin="2"                           
                            Command="{Binding DeleteSelected}">
                        <TextBlock>Delete<LineBreak/>Selected</TextBlock>
                    </Button>
                    <Button x:Name="CancelButton" Margin="2"                           
                            Command="{Binding CancelActive}">
                        <TextBlock>Cancel<LineBreak/>Action</TextBlock>
                    </Button>
                </StackPanel>
                <StackPanel Orientation="Horizontal">
                    <Button x:Name="EditVerticesButton" Margin="2"                        
                         Command="{Binding EditVertices}">
                        <TextBlock>Edit Vertices<LineBreak/>/Move Selected</TextBlock>
                    </Button>
                    <Button x:Name="CutButton" Margin="2"                            
                            Command="{Binding Cut}">
                        <TextBlock>Cut<LineBreak/>Selected</TextBlock>
                    </Button>
                    <Button x:Name="ReshapeButton" Margin="2"                           
                            Command="{Binding Reshape}">
                        <TextBlock>Reshape<LineBreak/>Selected</TextBlock>
                    </Button>
                    <Button x:Name="UnionButton" Margin="2"                           
                            Command="{Binding Union}">
                        <TextBlock>Union<LineBreak/>Selected</TextBlock>
                    </Button>
                    <Button x:Name="SaveButton" Margin="2"                           
                            Command="{Binding Save}">
                        <TextBlock FontWeight="Bold">Save<LineBreak/>Edits</TextBlock>
                    </Button>
                    <Button x:Name="CancelEditsButton" Margin="2"                             
                            Click="CancelEditsButton_Click" >
                        <TextBlock FontWeight="Bold">Cancel<LineBreak/>Edits</TextBlock>
                    </Button>
                </StackPanel>
                <StackPanel Orientation="Horizontal">
                    <CheckBox x:Name="FreehandCheckBox" VerticalAlignment="Center" Margin="2" Foreground="White"
                          IsChecked="{Binding Path=Freehand, Mode=TwoWay}" 
                          Content="Freehand Draw" />
                    <CheckBox x:Name="AutoCompleteCheckBox" VerticalAlignment="Center" Margin="2" Foreground="White"
                          IsChecked="{Binding Path=AutoComplete, Mode=TwoWay}" 
                          Content="Auto Complete" />
                    <CheckBox x:Name="AutoSelectCheckBox" VerticalAlignment="Center" Margin="2" Foreground="White"
                          IsChecked="{Binding Path=AutoSelect, Mode=TwoWay}" 
                          Content="Auto Select" />
                    <CheckBox x:Name="ContinuousCheckBox" VerticalAlignment="Center" Margin="2" Foreground="White"
                          IsChecked="{Binding Path=ContinuousMode, Mode=TwoWay}" 
                          Content="Continuous Action" />
                </StackPanel>
            </StackPanel>
        </Border>
        <Grid HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,10,10,0" >
            <Rectangle Fill="{StaticResource PanelGradient}" Stroke="Gray"  RadiusX="10" RadiusY="10" Margin="0,0,0,5">
                <Rectangle.Effect>
                    <DropShadowEffect/>
                </Rectangle.Effect>
            </Rectangle>
            <Rectangle Fill="#FFFFFFFF" Stroke="DarkGray" RadiusX="5" RadiusY="5" Margin="10,10,10,15" />
            <TextBlock x:Name="ResponseTextBlock" Text="Use the Add Polygon button to enable drawing a polygon on the map.  Use other buttons to move, modify, select or delete features.  Use the Save Edits button to commit edits to the database.  Cancel Edits will clear all edits up to that point."
                       Width="200" TextAlignment="Left" Margin="30,20,20,30" TextWrapping="Wrap" Foreground="Black" />
        </Grid>
        <ProgressBar x:Name="MyProgressBar" IsIndeterminate="True" VerticalAlignment="Bottom" Width="200" Height="20" Margin="10" Visibility="{Binding Path=IsBusy, Converter={StaticResource BooleanToVisibilityConverter}}"></ProgressBar>
    </Grid>
</UserControl>
Sample code usage restrictions
5/16/2014