I am trying to edit a field whenever an edit occurs on a feature layer, however when I make the edit the OnEditCompletedEvent fires again because of my edit. This also causes problems with undo, because anytime I undo something the OnEditCompletedEvent fires so if I undo my edit, it just gets re-edited back in. Is there any way around this?
Solved! Go to Solution.
Kyle,
You can assign your EditOperation an event token then check for that on the next pass.
You can also use the CompletedType property on EditCompletedEventArgs to check for the type of operation that is firing the event (save/discard, undo/redo, an operation). EditCompletedEvent fires often.
What sorts of edits are you doing here?
Here's an example that would need more trapping.
private Task onEditCompletedEvent(EditCompletedEventArgs arg)
{
if ((int?)arg.EventToken == 42)
return Task.CompletedTask;
var mapLayers = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>();
var editop = new EditOperation();
editop.Name = "Extra edit";
editop.EventToken = 42;
editop.Create(mapLayers.First());
editop.Execute();
return Task.CompletedTask;
}
Kyle,
You can assign your EditOperation an event token then check for that on the next pass.
You can also use the CompletedType property on EditCompletedEventArgs to check for the type of operation that is firing the event (save/discard, undo/redo, an operation). EditCompletedEvent fires often.
What sorts of edits are you doing here?
Here's an example that would need more trapping.
private Task onEditCompletedEvent(EditCompletedEventArgs arg)
{
if ((int?)arg.EventToken == 42)
return Task.CompletedTask;
var mapLayers = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>();
var editop = new EditOperation();
editop.Name = "Extra edit";
editop.EventToken = 42;
editop.Create(mapLayers.First());
editop.Execute();
return Task.CompletedTask;
}
Hey Sean,
Thanks for the reply. I am editing a Field on the Feature Class, but I am actually using an inspector to do the edits. This solutions seems good though. Is there a similar way to do that in the Inspector class?
Not directly, but note that EditOperation.Modify(Inspector) does pretty much the same things as Inspector.Apply() does.