ArcGIS Pro 3.2 API Reference Guide
ArcGIS.Desktop.Layouts Namespace / LayoutView Class / CanActivateMapFrame Method
The mapframe to check
Example

In This Topic
    CanActivateMapFrame Method
    In This Topic
    Check whether or not the given map frame can be activated on the layout view
    Syntax
    public bool CanActivateMapFrame( 
       MapFrame mapFrame
    )
    Public Function CanActivateMapFrame( _
       ByVal mapFrame As MapFrame _
    ) As Boolean

    Parameters

    mapFrame
    The mapframe to check

    Return Value

    True if the map frame can be activated on this view
    Remarks
    To be activated, a map frame must have a valid map, be visible on the current layout (being shown on the view), and not already be activated. If another map frame is currently activated on the view then CanActivateMapFrame will also return false.
    Example
    Activate Map Frame
    //The active view must be a layout view.
    var lv = LayoutView.Active;
    if (lv == null)
      return;
    var layout = lv.Layout;
    if (layout == null)
      return;
    
    //We can activate a map frame on the layout of the active view
    var map_frame = layout.GetElementsAsFlattenedList()
                       .OfType<MapFrame>().FirstOrDefault(mf => mf.Name == "Map 1");
    if (map_frame == null)
      return;
    //can we activate the map frame?
    if (lv.CanActivateMapFrame(map_frame))
      //activate it - Note: we are on the UI thread!
      lv.ActivateMapFrame(map_frame);
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.1 or higher.
    See Also