ArcGIS Pro 删除记录时提示
protected override void OnClick() { QueuedTask.Run(() => { Table table = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault().GetTable(); RowDeletedEvent.Subscribe(OnRowDeletedEvent, table); }); } private static Guid _lastEdit = Guid.Empty; private static void OnRowDeletedEvent1(RowChangedEventArgs obj) { if (_lastEdit != obj.Guid) { //cancel with dialog // Note - feature edits on Hosted and Standard Feature Services cannot be cancelled. obj.CancelEdit("Delete Event\nAre you sure", true); _lastEdit = obj.Guid; } } public static long CurrentlyDeletingOID = 0; protected static void OnRowDeletedEvent(RowChangedEventArgs args) { try { long _deletingOID = args.Row.GetObjectID(); if (CurrentlyDeletingOID != _deletingOID) { MessageBoxResult mbr = ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show( "Are you sure you want to Delete this Feature?", "Confirm Delete", MessageBoxButton.YesNo, MessageBoxImage.Warning); if (mbr == MessageBoxResult.Yes) { //PROCEED with the delete args.CancelEdit(() => Task.FromResult(true)); //Need to set this so that the code doesn't get stuck in loop, no need to reset CurrentlyDeletingOID = _deletingOID; } else { //CANCEL the Delete args.CancelEdit(() => Task.FromResult(false)); } //cancel with dialog using ESRI commands //args.CancelEdit("Delete Event\nAre you sure", true); } } catch (Exception e) { //logError("onRowDeleteEvent", e); } }