ArcGIS Pro 3.3 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / GraphicsLayerExtensions Class / UnSelectElement Method
The selected element to unselect. Cannot be null
Example

In This Topic
    UnSelectElement Method (GraphicsLayerExtensions)
    In This Topic
    Unselect the element within the GraphicsLayer collection. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    public static void UnSelectElement( 
       GraphicsLayer graphicsLayer,
       Element element
    )
    Public Shared Sub UnSelectElement( _
       ByVal graphicsLayer As GraphicsLayer, _
       ByVal element As Element _
    ) 

    Parameters

    graphicsLayer
    element
    The selected element to unselect. Cannot be null
    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.
    Example
    Un-Select Graphic elements
    var graphicsLayer = MapView.Active.Map.GetLayersAsFlattenedList()
                        .OfType<ArcGIS.Desktop.Mapping.GraphicsLayer>().FirstOrDefault();
    if (graphicsLayer == null)
      return;
    //unselect the first element in the currently selected elements
    var elem = graphicsLayer.GetSelectedElements().FirstOrDefault();
    QueuedTask.Run( () => {
      if (elem != null)
        //Unselect one element
        graphicsLayer.UnSelectElement(elem);
    
      //unselect all elements
      graphicsLayer.UnSelectElements();
      //equivalent to
      graphicsLayer.ClearSelection();
    });
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also