When you edit a feature returned by QueryTask, you are not affecting the same instance contained in your FeatureLayer. You need to edit features from your FeatureLayer.Graphics.
As Thang mentionned, the closest sample of what you have to do is this one : http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#ToolkitFeatureDataFormIt could be a good idea to make first working this sample in your context and then try to adapt it to your exact need.
private void MyFeatureLayer_MouseLeftButtonUp(object sender, GraphicMouseButtonEventArgs args) { FeatureLayer featureLayer = sender as FeatureLayer; //references MyFeatureLayer defined in Map Layers in xaml featureDataForm.FeatureLayer = featureLayer; featureDataForm.GraphicSource = args.Graphic; }
private void MyFeatureLayer_MouseLeftButtonUp(object sender, GraphicMouseButtonEventArgs args) { FeatureLayer featureLayer = sender as FeatureLayer; //perform query instead on the objectid, to demonstrate query int objectId = (int) args.Graphic.Attributes["OBJECTID"]; QueryTask queryTask = new QueryTask(featureLayer.Url); queryTask.ExecuteCompleted += MS4QueryTask_ExecuteCompleted; queryTask.Failed += MS4QueryTask_Failed; Query query = new ESRI.ArcGIS.Client.Tasks.Query(); query.ObjectIDs = new int[1] { objectId }; query.OutFields.Add("*"); query.ReturnGeometry = true; //If query is sucessful fire off AQueryTask_ExecuteCompleted queryTask.ExecuteAsync(query); } private void MS4QueryTask_ExecuteCompleted(object sender, ESRI.ArcGIS.Client.Tasks.QueryEventArgs args) { FeatureSet featureSet = args.FeatureSet; if (featureSet != null && featureSet.Features.Count > 0) { foreach (Graphic feature in featureSet.Features) { //should only be 1 since we searched on objectid featureDataForm.FeatureLayer = MyFeatureLayer; featureDataForm.GraphicSource = args.Graphic; } } }
I worked at it all day today with no results, can you give me any more information?
MyFeatureDataForm.GraphicSource = SelectedGraphic;
<esri:FeatureDataForm x:Name="MyFeatureDataForm" FeatureLayer="{Binding Path=Layers[PointLayer], ElementName=MyMap}" IsReadOnly="False" LabelPosition="Left" />
private void EditButton_Click(object sender, RoutedEventArgs e) { QueryTask queryTask = new QueryTask("http://localhost/ArcGIS/rest/services/Caledonia/CaledoniaEDIT/FeatureServer/1"); queryTask.ExecuteCompleted += editAttribute_data; queryTask.Failed += QueryTask_Failed; ESRI.ArcGIS.Client.Tasks.Query query = new ESRI.ArcGIS.Client.Tasks.Query(); query.Where = string.Format("id = " + _pointID); query.OutFields.Add("*"); query.ReturnGeometry = true; queryTask.ExecuteAsync(query); }
private void editAttribute_data(object sender, ESRI.ArcGIS.Client.Tasks.QueryEventArgs args) { FeatureSet featureSet = args.FeatureSet; GraphicsLayer graphicsLayer = Map.Layers["MySelectionGraphicsLayer"] as GraphicsLayer; graphicsLayer.ClearGraphics(); Graphic selectedFeature = featureSet.Features[0]; selectedFeature.Symbol = LayoutRoot.Resources["DefaultMarkerSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol; graphicsLayer.Graphics.Add(selectedFeature); MyFeatureDataForm.GraphicSource = ?????; }
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.