Thanks Sanjay, Dominique and Gert.I solved my problem and below is the code for the one method and its event handler (cf. code below). Yes, "UpdateCompleted" did it.The collection sent by the feature service keeps its reference all the way through; one cannot just assign the returned graphics to the existing graphics layer bound to the feature data grid. I had to create a nested loop (cf. FeatureLayer_UpdateCompleted) and copy the geometry and attributes to the new graphic. Then, I inserted the new graphic to the existing graphics layer bound to the feature data grid. (I learned from Dominique not to use "ItemsSource" to bind features to the feature data grid: update the graphics layer associated with it, instead.)Thanks a lot!Hugo.public void ReLoadMeters(string sql)
{
/* Retrieve meters for the alert type check box status */
ESRI.ArcGIS.Client.FeatureLayer fs = new ESRI.ArcGIS.Client.FeatureLayer();
// Set event handler on feature layer feature retrieval.
fs.UpdateCompleted += FeatureLayer_UpdateCompleted;
fs.Url = MetersFeatureService;
if (!string.IsNullOrWhiteSpace(sql)) fs.Where = sql;
fs.Mode = FeatureLayer.QueryMode.OnDemand;
fs.Renderer = AlertTypesRenderer;
fs.OutFields.Add("*");
fs.Visible = true;
fs.ID = MetersMapName;
// Add the new meters to the map. Remove the old layer first
int index = MyMap.Layers.IndexOf(MyMap.Layers[MetersMapName]);
if (index >= 0)
{
try
{
MyMap.Layers.RemoveAt(index);
MyMap.Layers.Insert(index, fs);
}
catch { }
}
}
private void FeatureLayer_UpdateCompleted(object sender, EventArgs args)
{
// Create instance of feature layer that just returned features from ArcGIS Cloud Server
ESRI.ArcGIS.Client.FeatureLayer fs = sender as ESRI.ArcGIS.Client.FeatureLayer;
// Clear graphics layer bound to feature data grid
_myFeatureDataGridLayer.ClearGraphics();
// Fill graphics layer for feature data grid
// Iterate through every feature sent by feature service
foreach (ESRI.ArcGIS.Client.Graphic graphic in fs.Graphics)
{
// Create a new graphic instance to prevent OutOfRangeException silent errors.
ESRI.ArcGIS.Client.Graphic gr = new ESRI.ArcGIS.Client.Graphic();
// Retrieve geometry
gr.Geometry = graphic.Geometry;
// Iterate through every attribute and copy it to new graphic.
foreach (KeyValuePair<string, object> kvp in graphic.Attributes)
{
gr.Attributes.Add(kvp);
}
// Insert new graphic to graphics layer bound to feature data grid
_myFeatureDataGridLayer.Graphics.Insert(0, gr);
}
}