ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Layouts.Events Namespace / ElementEventArgs Class / Elements Property
Example

In This Topic
    Elements Property (ElementEventArgs)
    In This Topic
    Gets the list of elements that have been updated.
    Syntax
    Public ReadOnly Property Elements As IElement()
    public IElement[] Elements {get;}
    Example
    Subscribe to ElementSelectionChangedEvent
    {
      ArcGIS.Desktop.Layouts.Events.ElementEvent.Subscribe((args) =>
      {
        //check if the container is a graphics layer - could be a Layout (or even map view)
        if (args.Container is ArcGIS.Desktop.Mapping.GraphicsLayer graphicsLayer)
        {
          //get the total selection count for the container
          var count = args.Elements.Count();
          //Check count - could have been an unselect or clearselect
          if (count > 0)
          {
            //this is a selection or add to selection
            var elems = graphicsLayer.GetSelectedElements();
            //TODO process the selection...
          }
          else
          {
            //This is an unselect or clear selection
            //TODO process the unselect or clear select
          }
        }
      });
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also