Thanks Jen. I went after a different aspect of Editing, specifically updating and deleting features from the code behind. Even thought it's been awhile, I'd thought I share my progress. I've used a Linq query to "link" the graphic to the Feature in the Feature Service. Should anyone try this code, just left mouse click on a feature to get started. This targets the feature for an update or a delete. The buttons in the application are responsible for doing the graphic selection and linq query.Hope this helps someone.
<UserControl x:Class="SDK.StandaloneTables"
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/client/2009"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk">
<Grid x:Name="LayoutRoot" Background="White">
<Grid.Resources>
<esri:Editor x:Key="MyEditor"
Map="{Binding ElementName=MyMap}"
LayerIDs="MyFeatureLayer"
GeometryServiceUrl="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer"/>
</Grid.Resources>
<esri:Map x:Name="MyMap">
<esri:ArcGISTiledMapServiceLayer
Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer" />
<esri:FeatureLayer ID="MyFeatureLayer" x:Name="MyFeatureLayer"
Url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/SanFrancisco/311Incidents/FeatureServer/0"
MouseLeftButtonUp="FeatureLayer_MouseLeftButtonUp"
AutoSave="False"
DisableClientCaching="True"
OutFields="*"
Mode="OnDemand" />
</esri:Map>
<Grid HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,15,15,0" >
<Rectangle Stroke="Gray" RadiusX="10" RadiusY="10" Fill="#77919191" 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" />
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="30,20,30,30" VerticalAlignment="Top" >
<sdk:Label Height="27" Content="Target the following ObjectId : " Width="170" Margin="0,10,0,0" />
<TextBox Height="23" x:Name="MyTextbox" Width="120" Margin="10,0,0,0"/>
</StackPanel>
<StackPanel Orientation="Vertical" HorizontalAlignment="Left" Margin="30,65,30,30" VerticalAlignment="Top">
<Button Height="23" Content="Update" x:Name="Update" Click="Update_Click" Width="100" Margin="5,5,5,5" HorizontalAlignment="Left" />
<Button Height="23" Content="Delete" x:Name="Delete" Click="Delete_Click" Width="100" Margin="5,5,5,5" HorizontalAlignment="Left" />
</StackPanel>
</Grid>
<Grid HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0,15,15,0" >
<Rectangle Stroke="Gray" RadiusX="10" RadiusY="10" Fill="#77919191" 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" />
<StackPanel Orientation="Vertical" HorizontalAlignment="Left" Margin="15,10,30,30" VerticalAlignment="Top">
<TextBlock Height="23" Margin="5,5,5,5" Name="textBlock1" Text="Left mouse click on a feature to identify:" />
<sdk:Label x:Name="objectid" Margin="5,5,5,5" HorizontalAlignment="Left" VerticalAlignment="Top"></sdk:Label>
<sdk:Label x:Name="reqtype" Margin="5,5,5,5" HorizontalAlignment="Left" VerticalAlignment="Top"></sdk:Label>
<sdk:Label x:Name="address" Margin="5,5,5,5" HorizontalAlignment="Left" VerticalAlignment="Top"></sdk:Label>
<sdk:Label x:Name="status" Margin="5,5,5,5" HorizontalAlignment="Left" VerticalAlignment="Top"></sdk:Label>
</StackPanel>
</Grid>
</Grid>
</UserControl>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Linq;
using ESRI.ArcGIS.Client;
using ESRI.ArcGIS.Client.Geometry;
using ESRI.ArcGIS.Client.Tasks;
namespace SDK
{
public partial class StandaloneTables : UserControl
{
private static ESRI.ArcGIS.Client.Projection.WebMercator _mercator =
new ESRI.ArcGIS.Client.Projection.WebMercator();
public StandaloneTables()
{
InitializeComponent();
ESRI.ArcGIS.Client.Geometry.Envelope initialExtent =
new ESRI.ArcGIS.Client.Geometry.Envelope(
_mercator.FromGeographic(
new ESRI.ArcGIS.Client.Geometry.MapPoint(-122.4306073721, 37.7666097907)) as MapPoint,
_mercator.FromGeographic(
new ESRI.ArcGIS.Client.Geometry.MapPoint(-122.4230971868, 37.77197420877)) as MapPoint);
initialExtent.SpatialReference = new SpatialReference(102100);
MyMap.Extent = initialExtent;
}
private void FeatureLayer_MouseLeftButtonUp(object sender, GraphicMouseButtonEventArgs e)
{
FeatureLayer featureLayer = sender as FeatureLayer;
for (int i = 0; i < featureLayer.SelectionCount; i++)
featureLayer.SelectedGraphics.ToList().UnSelect();
MyTextbox.Text = e.Graphic.Attributes["objectid"].ToString();
objectid.Content = "ObjectId: " + e.Graphic.Attributes["objectid"].ToString();
reqtype.Content = "Required Type: " + e.Graphic.Attributes["req_type"].ToString();
address.Content = "Address: " + e.Graphic.Attributes["address"].ToString();
status.Content = "Status: " + e.Graphic.Attributes["status"].ToString();
}
private void Update_Click(object sender, RoutedEventArgs e)
{
FeatureLayer featureLayer = MyMap.Layers["MyFeatureLayer"] as FeatureLayer;
IEnumerable<Graphic> graphicEnum;
graphicEnum = (from g in featureLayer.Graphics
where g.Attributes["objectid"].ToString() == MyTextbox.Text
select g);
List<Graphic> graphicList = graphicEnum.ToList<Graphic>();
foreach (ESRI.ArcGIS.Client.Graphic linqedGraphic in graphicList)
{
linqedGraphic.Select();
System.Diagnostics.Debug.WriteLine
(string.Format("{0}{1}{2}{3}", "Preparing to update objectid ", linqedGraphic.Attributes["objectid"], " that has a current address field set to ", linqedGraphic.Attributes["address"]));
//Change the address to be 114 South Buena Vista Street
linqedGraphic.Attributes["address"] = "114 South Buena Vista Street";
featureLayer.SaveEdits();
}
}
private void Delete_Click(object sender, RoutedEventArgs e)
{
FeatureLayer featureLayer = MyMap.Layers["MyFeatureLayer"] as FeatureLayer;
Editor editor = LayoutRoot.Resources["MyEditor"] as Editor;
IEnumerable<Graphic> graphicEnum;
graphicEnum = (from g in featureLayer.Graphics
where g.Attributes["objectid"].ToString() == MyTextbox.Text
select g);
List<Graphic> graphicList = graphicEnum.ToList<Graphic>();
foreach (ESRI.ArcGIS.Client.Graphic linqedGraphic in graphicList)
{
linqedGraphic.Select();
System.Diagnostics.Debug.WriteLine
(string.Format("{0}{1}", "Preparing to delete objectid ", linqedGraphic.Attributes["objectid"]));
if (editor.DeleteSelected.CanExecute(null))
editor.DeleteSelected.Execute(null);
}
}
}
}
Regards, Doug Carroll, ESRI Support Services SDK Team http://support.esri.com/