FindElement Method (GraphicsLayerExtensions)
Finds the element recursively with the given name within the GraphicsLayer collection.
This method must be called on the MCT. Use QueuedTask.Run.
Parameters
- graphicsLayer
- The graphics layer being extended
- elementName
- The name of the element to find. Cannot be null
Return Value
The
ArcGIS.Desktop.Layouts.Element or null if it is not found
Modify symbology of a Graphic Element
//within a queued Task
//get the first line element in the layer
var ge = graphicsLayer.FindElement("Line 10") as GraphicElement;
var graphic = ge.GetGraphic();
if (graphic is CIMLineGraphic lineGraphic)
{
//change its symbol
lineGraphic.Symbol =
SymbolFactory.Instance.ConstructLineSymbol(
SymbolFactory.Instance.ConstructStroke(
ColorFactory.Instance.BlueRGB, 2, SimpleLineStyle.DashDot)).MakeSymbolReference();
//apply the change
ge.SetGraphic(lineGraphic);
}
Target Platforms: Windows 11, Windows 10
ArcGIS Pro version: 3 or higher.