ArcGIS Pro 3.5 API Reference Guide
ArcGIS.Desktop.Presentations.Events Namespace / PresentationViewEvent Class / Subscribe Method
The delegate that gets executed when the event is published.
When false the CompositePresentationEvent will maintain a weak delegate reference to the subscriber. Using a weak delegate reference relieves the subscriber from the need to unsubscribe to enable proper garbage collection. The default is false.
Example

In This Topic
    Subscribe Method (PresentationViewEvent)
    In This Topic
    Subscribe to the PresentationViewEvent.
    Syntax

    Parameters

    action
    The delegate that gets executed when the event is published.
    keepSubscriberAlive
    When false the CompositePresentationEvent will maintain a weak delegate reference to the subscriber. Using a weak delegate reference relieves the subscriber from the need to unsubscribe to enable proper garbage collection. The default is false.

    Return Value

    A SubscriptionToken that uniquely identifies the added subscription.
    Example
    Detect changes to the presentation view
    //For UI context changes associated with a presentation, subscribe to the PresentationView
    //event - views activated/deactivated, views opened/closed
    ArcGIS.Desktop.Presentations.Events.PresentationViewEvent.Subscribe((args) =>
    {
      //get the affected view and presentation
      var view = args.PresentationView;
      var presentation = args.PresentationView?.Presentation;
      if (presentation == null)
      {
        //FYI presentationview and/or presentation can be null...
        //eg closed, deactivation
      }
      //Check what triggered the event and take appropriate action
      switch (args.Hint)
      {
        case PresentationViewEventHint.Activated:
          // Presentation view activated
          break;
        case PresentationViewEventHint.Opened:
          //A PresentationView has been initialized and opened
          break;
        case PresentationViewEventHint.Deactivated:
          // Presentation view deactivated
          break;
        case PresentationViewEventHint.Closing:
          //Set args.Cancel = true to prevent closing
          break;
        case PresentationViewEventHint.ExtentChanged:
          //presentation view extent has changed
          break;
        case PresentationViewEventHint.DrawingComplete:
          break;
        case PresentationViewEventHint.PauseDrawingChanged:
          break;
      }
    });
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.5 or higher.
    See Also