ArcGIS Pro 3.0 API Reference Guide
ArcGIS.Desktop.Layouts.Events Namespace / LayoutEvent 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 (LayoutEvent)
    In This Topic
    Subscribe to the LayoutEvent.
    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
    LayoutEvent_PropertyChanged
    //Report the event args when a layout is changed.
    
    //At 2.x - ArcGIS.Desktop.Layouts.Events.LayoutChangedEvent.Subscribe((args) =>
    //{
    //  System.Windows.MessageBox.Show("LayoutChangedEvent:" +
    //  Environment.NewLine +
    //  "   arg Layout: " + args.Layout.Name);
    //});
    
    ArcGIS.Desktop.Layouts.Events.LayoutEvent.Subscribe((args) =>
    {
      var layout = args.Layout;
      if (args.Hint == LayoutEventHint.PropertyChanged)
      {
        System.Diagnostics.Debug.WriteLine($"Layout PropertyChanged: {layout.Name}");
      }
    });
    
    LayoutEvent_MapSeries
    //Report the event args when the map series properties have changed.
    
    //At 2.x - ArcGIS.Desktop.Layouts.Events.MapSeriesEvent.Subscribe((args) =>
    //{
    //  System.Windows.MessageBox.Show("MapSeriesEvent:" +
    //  Environment.NewLine +
    //  "   arg CurrentPageName: " + args.CurrentPageName.ToString() +
    //  Environment.NewLine +
    //  "   arg CurrentlPageNumber: " + args.CurrentPageNumber.ToString() +
    //  Environment.NewLine +
    //  "   arg Layout: " + args.Layout.Name +
    //  Environment.NewLine +
    //  "   arg Type: " + args.Type.ToString());
    //});
    
    ArcGIS.Desktop.Layouts.Events.LayoutEvent.Subscribe((args) =>
    {
      var layout = args.Layout;
      if (args.Hint == LayoutEventHint.MapSeriesRefreshed ||
        args.Hint == LayoutEventHint.MapSeriesPageChanged)
      {
        var ms = layout.MapSeries;
        System.Diagnostics.Debug.WriteLine($"LayoutEvent {args.Hint.ToString()}: {layout.Name}");
      }
    });
    
    LayoutEvent_PageChanged
    //Report the event args when a layout page properties are changed.
    
    //At 2.x - ArcGIS.Desktop.Layouts.Events.PageChangedEvent.Subscribe((args) =>
    //{
    //  System.Windows.MessageBox.Show("PageChangedEvent:" +
    //  Environment.NewLine +
    //  "   arg Layout: " + args.Layout.Name +
    //  Environment.NewLine +
    //  "   arg New CIMPage (height): " + args.NewPage.Height.ToString() +
    //  Environment.NewLine +
    //  "   arg Old CIMPage (height): " + args.OldPage.Height.ToString());
    //});
    
    ArcGIS.Desktop.Layouts.Events.LayoutEvent.Subscribe((args) =>
    {
      var layout = args.Layout;
      if (args.Hint == LayoutEventHint.PageChanged)
      {
        var cimPage = args.OldPage;
        System.Diagnostics.Debug.WriteLine($"LayoutEvent {args.Hint.ToString()}: {layout.Name}");
      }
    });
    
    Requirements

    Target Platforms: Windows 11, Windows 10, Windows 8.1

    See Also