ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Framework Namespace / FrameworkApplication Class / Panes Property
Example

In This Topic
    Panes Property
    In This Topic
    Gets all the active pane instances; this singleton also lets you activate, create, and close panes.
    Syntax
    Public Shared ReadOnly Property Panes As PaneCollection
    public static PaneCollection Panes {get;}
    Example
    Close a specific pane
    {
      List<uint> myPaneInstanceIDs = [];
      foreach (Pane p in FrameworkApplication.Panes)
      {
        if (p.ContentID == paneID)
        {
          myPaneInstanceIDs.Add(p.InstanceID); //InstanceID of your pane, could be multiple, so build the collection                    
        }
      }
      foreach (var instanceID in myPaneInstanceIDs) //close each of "your" panes.
      {
        FrameworkApplication.Panes.ClosePane(instanceID);
      }
    }
    Activate a pane
    {
      var mapPanes = FrameworkApplication.Panes.OfType<IMapPane>();
      foreach (Pane p in mapPanes.Cast<Pane>())
      {
        if (p.Caption == paneID)
        {
          p.Activate();
          break;
        }
      }
    }
    Find a MapView by its Caption
    {
      string mapPaneCaption = "USNationalParks";
      IMapPane mapViewPane = FrameworkApplication.Panes.OfType<IMapPane>().FirstOrDefault((p) => p.Caption == mapPaneCaption);
      mapView = null;
      if (mapViewPane != null)
      {
        // activate the MapPane
        (mapViewPane as Pane).Activate();
    
        if (mapView != null)
        {
          // get the layers selected in the map's TOC
          var selectedLayers = mapView.GetSelectedLayers();
        }
      }
    }
    Change table View caption
    {
      // find all the table panes (table panes hosting map data)
      var tablePanes = FrameworkApplication.Panes.OfType<ITablePane>();
      var tablePane = tablePanes.FirstOrDefault(p => p is ITablePaneEx { Caption: "oldCaption" });
      if (tablePane is ITablePaneEx tablePaneEx)
        tablePaneEx.Caption = "newCaption";
    
      // find all the external table panes (table panes hosting external data)
      var externalPanes = FrameworkApplication.Panes.OfType<IExternalTablePane>();
      var externalTablePane = externalPanes.FirstOrDefault(p => p.Caption == "oldCaption");
      if (externalTablePane != null)
        externalTablePane.Caption = "newCaption";
    }
    Get TableView from table pane
    {
      // find all the table panes (table panes hosting map data)
      var tablePanes = FrameworkApplication.Panes.OfType<ITablePane>();
      var tablePane = tablePanes.FirstOrDefault(p => p is ITablePaneEx { Caption: "caption" });
      if (tablePane is ITablePaneEx tablePaneEx)
        tableView = tablePaneEx.TableView;
    
      // if it's not found, maybe it's an external table pane
      if (tableView == null)
      {
        // find all the external table panes (table panes hosting external data)
        var externalPanes = FrameworkApplication.Panes.OfType<IExternalTablePane>();
        var externalTablePane = externalPanes.FirstOrDefault(p => p.Caption == "caption");
        if (externalTablePane != null)
          tableView = externalTablePane.TableView;
      }
    }
    Activate an already open layout view
    {
      //Activate an already open layout view.
      //A layout view may be open but it may not be active.
    
      //Find the pane that references the layout and activate it. 
      //Note - there can be multiple panes referencing the same layout.
      foreach (var pane in ProApp.Panes)
      {
        var layoutPane = pane as ILayoutPane;
        if (layoutPane == null)  //if not a layout view, continue to the next pane
          continue;
        if (layoutPane.LayoutView.Layout == layout) //activate the view
        {
          (layoutPane as Pane).Activate();
          return;
        }
      }
    }
    Requirements

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

    ArcGIS Pro version: 3.0 or higher.
    See Also