ArcGIS Pro 3.1 API Reference Guide
ArcGIS.Desktop.Framework.Contracts Namespace / Pane Class / Activate Method
Example

In This Topic
    Activate Method (Pane)
    In This Topic
    Makes the Pane the active Pane and active window.
    Syntax
    public void Activate()
    Public Sub Activate() 
    Example
    Activate a pane
    var mapPanes = ProApp.Panes.OfType<IMapPane>();
    foreach (Pane pane in mapPanes)
    {
      if (pane.Caption == "MyMap")
      {
        pane.Activate();
        break;
      }
    }
    LayoutView_LayoutFrameWorkExtender
    //This sample checks to see if a layout project item already has an open application pane.  
    //If it does, it checks if it is the active layout view, if not, it creates, activates and opens a new pane.
    
    //Reference a layoutitem in a project by name
    LayoutProjectItem layoutItem = Project.Current.GetItems<LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals("Layout View"));
    
    //Get the layout associated with the layoutitem
    Layout lyt = await QueuedTask.Run(() => layoutItem.GetLayout());
          
    //Iterate through each pane in the application and check to see if the layout is already open and if so, activate it
    foreach (var pane in ProApp.Panes)
    {
      var layoutPane = pane as ILayoutPane;
      if (layoutPane == null)  //if not a layout pane, continue to the next pane
        continue;
      if (layoutPane.LayoutView.Layout == lyt)  //if the layout pane does match the layout, activate it.
      {
        (layoutPane as Pane).Activate();
        layoutPane.Caption = "This is a test";
        System.Windows.MessageBox.Show(layoutPane.Caption);
        return;
      }
    }
    //Otherwise, create, open, and activate the layout if not already open
    ILayoutPane newPane = await ProApp.Panes.CreateLayoutPaneAsync(lyt);
    
    //Zoom to the full extent of the layout
    await QueuedTask.Run(() => newPane.LayoutView.ZoomTo100Percent());
    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;
      }
    }
    Activate an already open report view
    Report report = Project.Current.GetItems<ReportProjectItem>().FirstOrDefault().GetReport();
    var reportPane = FrameworkApplication.Panes.FindReportPanes(report).Last();
    if (reportPane == null)
      return;
    //Activate the pane
    (reportPane as ArcGIS.Desktop.Framework.Contracts.Pane).Activate();
    //Get the "ReportView" associated with the Report Pane.
    ReportView reportView = reportPane.ReportView;
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.0 or higher.
    See Also