ArcGIS Pro 3.5 API Reference Guide
ArcGIS.Desktop.Core Namespace / PresentationFrameworkExtender Class / CreatePresentationPaneAsync Method
Does not need to be specified.
Presentation
Example

In This Topic
    CreatePresentationPaneAsync Method
    In This Topic
    Creates and activates a new presentation pane using a Presentation reference. Must be called on GUI thread.
    Syntax
    public static Task<IPresentationPane> CreatePresentationPaneAsync( 
       PaneCollection paneCollection,
       Presentation presentation
    )
    Public Shared Function CreatePresentationPaneAsync( _
       ByVal paneCollection As PaneCollection, _
       ByVal presentation As Presentation _
    ) As Task(Of IPresentationPane)

    Parameters

    paneCollection
    Does not need to be specified.
    presentation
    Presentation

    Return Value

    Exceptions
    ExceptionDescription
    Must be called on GUI thread
    Remarks
    Be sure to call this on the GUI thread. Do not execute within a QueuedTask.Run block.
    Example
    Reference an existing presentation
    //Reference a presentation associated with an active presentation view
    PresentationView activePresentationView = PresentationView.Active;
    if (activePresentationView != null)
    {
      Presentation presentation = activePresentationView.Presentation;
    }
    Open a presentation project item in a new view
    //Open a presentation project item in a new view.
    //A presentation project item may exist but it may not be open in a view. 
    
    //Reference a presentation project item by name
    PresentationProjectItem presentationPrjItem = Project.Current.GetItems<PresentationProjectItem>().FirstOrDefault(item => item.Name.Equals(presentationName));
    
    //Get the presentation associated with the presentation project item
    Presentation presentationToOpen = await QueuedTask.Run(() => presentationPrjItem.GetPresentation());
    
    //Create the new pane
    IPresentationPane iNewPresentationPane = await ProApp.Panes.CreatePresentationPaneAsync(presentationToOpen); //GUI thread
    Activate a presentation view
    //Assume we want to open a view for a particular presentation or activate a view if one is already open
    
    //A presentation project item is an item that appears in the Presentation folder in the Catalog pane.
    PresentationProjectItem presentationItem = Project.Current.GetItems<PresentationProjectItem>()
                                                 .FirstOrDefault(item => item.Name.Equals(presentationName));
    
    //Reference a presentation associated with a presentation project item
    if (presentationItem != null)
    {
      //Get the presentation associated with the presentationItem
      Presentation presentationToOpen = await QueuedTask.Run(() => presentationItem.GetPresentation());
    
      //Next check to see if a presentation view is already open that references the presentation
      foreach (var pane in ProApp.Panes)
      {
        var prePane = pane as IPresentationPane;
        if (prePane == null)  // Not a presentation view, continue to the next pane
          continue;
    
        //if there is a match, activate the view
        if (prePane.PresentationView.Presentation == presentationToOpen)
        {
          (prePane as Pane).Activate();
          return;
        }
      }
    
      //No pane found, activate a new one - must be called on UI
      IPresentationPane iNewPresentationPane = await ProApp.Panes.CreatePresentationPaneAsync(presentationToOpen); //GUI thread
    }
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.5 or higher.
    See Also