ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Layouts Namespace / LayoutView Class / GetSelectedElements Method
Example

In This Topic
    GetSelectedElements Method (LayoutView)
    In This Topic
    Returns a collection of selected layout elements.
    Syntax
    Public Function GetSelectedElements() As IReadOnlyList(Of Element)
    public IReadOnlyList<Element> GetSelectedElements()

    Return Value

    A collection of page layout elements.
    Example
    Get element selection count
    {
      //Get element's selection count.
      //Count the number of selected elements on the active layout view
      LayoutView activeLayoutView = LayoutView.Active;
      if (activeLayoutView != null)
      {
        var selectedElements = activeLayoutView.GetSelectedElements();
        ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show($@"Selected elements: {selectedElements.Count}");
      }
    }
    Set halo property of north arrow
    {
      //Set the CIM halo properties of a north arrow.
    
      //Reference the first selected north arrow element
      var northArrow = LayoutView.Active.GetSelectedElements().OfType<NorthArrow>().First();
    
      //Note: Must be on QueuedTask.Run
      //Get definition of north arrow...
      var cim = northArrow.GetDefinition() as CIMMarkerNorthArrow;
    
      //this halo symbol is 50% transparent, no outline (i.e. 0 width)
      //First construct a polygon symbol to use in the Halo
      //Polygon symbol will need a fill and a stroke
      var polyFill = SymbolFactory.Instance.ConstructSolidFill(ColorFactory.Instance.CreateRGBColor(0, 0, 0, 50));
      var polyStroke = SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.BlackRGB, 0);
      var haloPoly = SymbolFactory.Instance.ConstructPolygonSymbol(polyFill, polyStroke);
    
      //Set the north arrow definition of HaloSymbol and HaloSize 
      ((CIMPointSymbol)cim.PointSymbol.Symbol).HaloSymbol = haloPoly;
      ((CIMPointSymbol)cim.PointSymbol.Symbol).HaloSize = 3;//size of the halo
    
      //Apply the CIM changes back to the element
      northArrow.SetDefinition(cim);
    }
    Requirements

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

    ArcGIS Pro version: 3.0 or higher.
    See Also