public static void ClearSelection( GraphicsLayer graphicsLayer )
Public Shared Sub ClearSelection( _ ByVal graphicsLayer As GraphicsLayer _ )
Parameters
- graphicsLayer
public static void ClearSelection( GraphicsLayer graphicsLayer )
Public Shared Sub ClearSelection( _ ByVal graphicsLayer As GraphicsLayer _ )
| Exception | Description |
|---|---|
| ArcGIS.Core.CalledOnWrongThreadException | This method or property must be called within the lambda passed to QueuedTask.Run. |
{
await QueuedTask.Run(() =>
{
// get the last location
var pt = DeviceLocationService.Instance.GetCurrentSnapshot()?.GetPositionAsMapPoint();
if (pt != null)
{
//Create a point symbol
var ptSymbol = SymbolFactory.Instance.ConstructPointSymbol(
CIMColor.CreateRGBColor(125, 125, 0), 10, SimpleMarkerStyle.Triangle);
//Add a graphic to the graphics layer
graphicsLayer.AddElement(pt, ptSymbol);
//unselect it
graphicsLayer.ClearSelection();
}
});
}
{
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();
});
}
Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)