Hello,
I have a button that creates a query task and finds a graphic. Now this works fine and on the QueryTask complete I asign the feature to a graphic. Then i try to remove this graphic from the FeatureLayer but it does not remove it. I can break the code and see the new graphic is the right one I want to delete from the feature layer but it does not delete it. Is there something im doing wrong?
Thanks for the help,
Craig
private void btnUploadDelete_Click(object sender, RoutedEventArgs e)
{
queryTask = new QueryTask(_clientInfo.PlanPointFeatureLayer);
queryTask.ExecuteCompleted += QueryTask_ExecuteCompleted;
Query query = new Query();
query.Where = "UniqueID = '" + uniqueID + "'";
query.ReturnGeometry = true;
query.OutSpatialReference = new SpatialReference(102100);
query.OutFields.Add("*");
queryTask.ExecuteAsync(query);
}
private void QueryTask_ExecuteCompleted(object sender, QueryEventArgs args)
{
FeatureSet featureSet = args.FeatureSet;
Graphic graphic = new Graphic();
if (featureSet != null && featureSet.Features.Count > 0)
{
foreach (Graphic feature in featureSet.Features)
{
graphic = feature;
}
}
FeatureLayer fLayer = MyMap.Layers["FeatureLayerPoint"] as FeatureLayer;
fLayer.Visible = true;
fLayer.Graphics.Remove(graphic);
fLayer.SaveEdits();
fLayer.Visible = false;
}