ArcGIS Pro 3.2 API Reference Guide
ArcGIS.Desktop.Framework Namespace / OperationManager Class / UndoAsync Method / UndoAsync(Int32,String) Method
The number of operations to roll back.
The category of operations to roll back.
Example

In This Topic
    UndoAsync(Int32,String) Method
    In This Topic
    Rolls back the specified number of operations belonging to the specified category.
    Syntax
    public Task UndoAsync( 
       int count,
       string category
    )
    Public Overloads Function UndoAsync( _
       ByVal count As Integer, _
       ByVal category As String _
    ) As Task

    Parameters

    count
    The number of operations to roll back.
    category
    The category of operations to roll back.

    Return Value

    A task that represents the work queued to execute in the ThreadPool.
    Example
    Undo/Redo the Most Recent Operation
    //undo
    if (MapView.Active.Map.OperationManager.CanUndo)
      MapView.Active.Map.OperationManager.UndoAsync();//await as needed
    
    //redo
    if (MapView.Active.Map.OperationManager.CanRedo)
      MapView.Active.Map.OperationManager.RedoAsync();//await as needed
    
    Dockpane undo / redo
    // in order to find a dockpane you need to know it's DAML id
    var pane = FrameworkApplication.DockPaneManager.Find("esri_core_contentsDockPane");
    
    // get the undo stack
    OperationManager manager = pane.OperationManager;
    if (manager != null)
    {
      // undo an operation
      if (manager.CanUndo)
        await manager.UndoAsync();
    
      // redo an operation
      if (manager.CanRedo)
        await manager.RedoAsync();
    
      // clear the undo and redo stack of operations of a particular category
      manager.ClearUndoCategory("Some category");
      manager.ClearRedoCategory("Some category");
    }
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also