ArcGIS Pro 3.6 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / MapView Class / SetMapTOCContentAsync Method
The content type to be set
Example

In This Topic
    SetMapTOCContentAsync Method
    In This Topic
    Sets the map TOC content type on the active TOC. This method must be called on the UI thread.
    Syntax
    public void SetMapTOCContentAsync( 
       MapTOCContentType mapTOCContentType
    )
    Public Sub SetMapTOCContentAsync( _
       ByVal mapTOCContentType As MapTOCContentType _
    ) 

    Parameters

    mapTOCContentType
    The content type to be set
    Exceptions
    ExceptionDescription
    The calling thread cannot access this object because a different thread owns it
    Remarks
    This method must be called from the UI thread or an System.InvalidOperationException will be thrown. The current active map TOC, if there is one, is searched for the specified map content type. If there is an active map TOC, and it has the requested map content type available, then its current content type will be set to the input mapTOCContentType. If the requested content type is not present in the TOC, or the TOC is not a map TOC, the request is ignored. Note: As link charts use a map TOC, SetMapTOCContentAsync(...) can also be used when a link chart is the active "map" view
    This method returns void and cannot be awaited.
    Example
    Set the Active Map TOC content type
          //Get the current active TOC content type for the map view 
          var mapTOCContentType = (int)MapView.Active.CurrentMapTOCContent;
    //increment to the next tab whatever it is
    mapTOCContentType++;
    //Can we set this type on the TOC?
          if (MapView.Active.CanSetMapTOCContent((MapTOCContentType)mapTOCContentType))
      //Set it - must be on the UI! - No QueuedTask
              MapView.Active.SetMapTOCContentAsync((MapTOCContentType)mapTOCContentType);
    else
    {
              mapTOCContentType = (int)MapTOCContentType.DrawingOrder;
              //Set it - must be on the UI! - No QueuedTask
              MapView.Active.SetMapTOCContentAsync((MapTOCContentType)mapTOCContentType);
          }
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.6 or higher.
    See Also