Not able to undo after EditOperation.Execute()

356
2
05-17-2023 12:22 AM
OscarYam
New Contributor III

I created a custom function to update a feature attribute.

I started by adding a dock pane and binding an update action to a button.

The update was a success, but I cannot undo it with the built-in undo button of ArcGIS Pro, which is dimmed. I can only discard the edit by using the discard button. I am wondering what's wrong. I would be grateful if anyone could point me in a direction.

part of the dock pane xaml

<Button Content="Update"
Command="{Binding Update}"/>

part of the C# of the ViewModel

private ICommand update;
public ICommand Update
{
	get
	{
		if (update == null)
		{
			update = new RelayCommand(() => UpdateFeatureNumber());
		}
		return update;
	}
}

private void UpdateFeatureNumber()
{
	QueuedTask.Run(() =>
	{
		EditOperation editOperation = new EditOperation
		{
			Name = "Update Attribute"
		};
		editOperation.Modify(currentRow, "Field", value);
		if (editOperation.Execute())
		{
			ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Updated.", "Update Attribute", MessageBoxButton.OK, MessageBoxImage.Information);
			return;
		}
	});
}

 

0 Kudos
2 Replies
by Anonymous User
Not applicable

Hi,

You need to override OperationManager method of your dockpane:

 

        public override OperationManager OperationManager
        {
            get
            {
                return MapView.Active?.Map.OperationManager;
            }
        }

 

More info you can find here:

https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic10432.html 

https://github.com/Esri/arcgis-pro-sdk/wiki/ProGuide-Dockpanes 

0 Kudos
Wolf
by Esri Regular Contributor
Esri Regular Contributor

In order to use Undo/Redo you have to 'save' your edits first.  More details are here:  ProConcepts Editing · Esri/arcgis-pro-sdk Wiki (github.com)

In short these are the relevant methods:

0 Kudos