ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Layouts Namespace / MapSurround Class / SetMapFrame Method
MapFrame
Example

In This Topic
    SetMapFrame Method
    In This Topic
    Sets a MapFrame to the MapSurround. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    Public Sub SetMapFrame( _
       ByVal mapFrame As MapFrame _
    ) 
    public void SetMapFrame( 
       MapFrame mapFrame
    )

    Parameters

    mapFrame
    MapFrame
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    Example
    Update a map surround
    {
      //Update a map surround.
      //Note: Must be on QueuedTask.Run
      // Reference and load the layout associated with the layout item
    
      // Reference a scale bar element by name
      MapSurround scaleBar = layout.FindElement("MyScaleBar") as MapSurround;
    
      // Reference a map frame element by name
      MapFrame mf = layout.FindElement("MyMapFrame") as MapFrame;
    
      if ((scaleBar != null) && (mf != null))
        //Set the scale bar to the newly referenced map frame
        scaleBar.SetMapFrame(mf);
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also