ArcGIS Pro 3.8 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / GraphicsLayerExtensions Class / UnSelectElements Method
The selected elements to unselect. If null then all elements are unselected
Example

In This Topic
    UnSelectElements Method (GraphicsLayerExtensions)
    In This Topic
    Unselect the elements within the GraphicsLayer collection. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    public static void UnSelectElements( 
       GraphicsLayer graphicsLayer,
       IEnumerable<Element> elements
    )
    Public Shared Sub UnSelectElements( _
       ByVal graphicsLayer As GraphicsLayer, _
       Optional ByVal elements As IEnumerable(Of Element) _
    ) 

    Parameters

    graphicsLayer
    elements
    The selected elements to unselect. If null then all elements are unselected
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    Remarks
    The map view displaying the graphics layer should be initialized.
    If a child of a group element is provided in the list of elements to be unselected in addition to its parent then the parent is the element unselected.
    Example
    Un-Select Graphic elements
    {
      await QueuedTask.Run(() =>
      {
        //unselect the first element in the currently selected elements
        var elem = graphicsLayer.GetSelectedElements().FirstOrDefault();
        if (elem != null)
        {
          //Unselect one element
          graphicsLayer.UnSelectElement(elem);
        }
    
        //unselect all elements
        graphicsLayer.UnSelectElements();
        //equivalent to
        graphicsLayer.ClearSelection();
      });
    }
    Requirements

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

    ArcGIS Pro version: 3.0 or higher.
    See Also