ArcGIS Pro 3.3 API Reference Guide
ArcGIS.Desktop.Layouts.Events Namespace / ElementEventArgs Class / Container Property
Example

In This Topic
    Container Property
    In This Topic
    Gets the element container.
    Syntax
    public IElementContainer Container {get;}
    Public ReadOnly Property Container As IElementContainer
    Example
    ElementEvent_SelectionChanged
    //Report the event args when a layout's selection has changed.
    
    //At 2.x - ArcGIS.Desktop.Layouts.Events.LayoutSelectionChangedEvent.Subscribe((args) => {
    //  var elements = args.Elements;
    //  string elemNames = "null";
    //  if (elements != null && elements.Count() > 0)
    //  {
    //    elemNames = string.Join(",", elements.Select(e => e.Name).ToList());
    //  }
    //  System.Windows.MessageBox.Show("LayoutSelectionChangedEvent:" +
    //  Environment.NewLine +
    //  "   arg Elements: " + elemNames.ToString() +
    //  Environment.NewLine +
    //  "   arg Layout: " + args.Layout.Name);
    //});
    
    ArcGIS.Desktop.Layouts.Events.ElementEvent.Subscribe((args) =>
    {
      if (args.Hint == ElementEventHint.SelectionChanged)
      {
        if (args.Container.GetSelectedElements()?.Count() > 0)
        {
          var elemNames = string.Join(",", args.Container.GetSelectedElements().Select(e => e.Name).ToList());
          System.Diagnostics.Debug.WriteLine($"ElementEventHint.SelectionChanged: {elemNames}");
        }
      }
    
    });
    ElementEvent_PropertyChanged
    //Report the event args when an element has been updated.
    
    //At 2.x - ArcGIS.Desktop.Layouts.Events.ElementsUpdatedEvent.Subscribe((args) => 
    //{
    //  var elements = args.Elements;
    //  string elemNames = "null";
    //  if (elements != null && elements.Count() > 0)
    //  {
    //    elemNames = string.Join(",", elements.Select(e => e.Name).ToList());
    //  }
    //  System.Windows.MessageBox.Show("ElementsUpdatedEvent:" +
    //  Environment.NewLine +
    //  "   arg Elements: " + elemNames.ToString() +
    //  Environment.NewLine +
    //  "   arg Layout: " + args.Layout.Name);
    //});
    ArcGIS.Desktop.Layouts.Events.ElementEvent.Subscribe((args) =>
    {
      string elemNames = "null";
      //can be null if the name was changed
      if (args.Elements?.Count() > 0)
      {
        elemNames = string.Join(",", args.Elements.Select(e => e.Name).ToList());
      }
      else if (args.Container.GetSelectedElements()?.Count() > 0)
      {
        elemNames = string.Join(",", args.Container.GetSelectedElements().Select(e => e.Name).ToList());
      }
    
      if (args.Hint == ElementEventHint.PropertyChanged)
      {
        System.Diagnostics.Debug.WriteLine($"ElementEventHint.PropertyChanged: {elemNames}");
      }
    });
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also