I apologize if this is a dumb question, I'm new.
I have a tool that allows a user to sketch a selection rectangle on a graphics layer, and I'm trying to set the Name property so I can refer to it again, but after adding the element to the layer, the Name property ends up being "Rectangle". This code is in OnSketchCompleteAsync:
Polygon box = geometry as Polygon;
QueuedTask.Run(() =>
{
var poly_symbol = SymbolFactory.Instance.ConstructPolygonSymbol(CIMColor.CreateRGBColor(130, 130, 130, 40));
var graphic = new CIMPolygonGraphic()
{
Symbol = poly_symbol.MakeSymbolReference(),
Polygon = box,
Name = "ExtentSelection"
};
displayLayer.AddElement(graphic);
});
What am I doing wrong?
Sorry, I figured it out. The Name needed to be set on the Element, not the CIMPolygonGraphic:
var poly_symbol = SymbolFactory.Instance.ConstructPolygonSymbol(CIMColor.CreateRGBColor(130, 130, 130, 40));
var graphic = new CIMPolygonGraphic()
{
Symbol = poly_symbol.MakeSymbolReference(),
Polygon = box
};
displayLayer.AddElement(graphic,"ExtentSelection");
Hi,
My code is a little bit different and it works on ArcGIS Pro 9.2
var poly_symbol = SymbolFactory.Instance.ConstructPolygonSymbol(CIMColor.CreateRGBColor(130, 130, 130, 40));
var graphic = new CIMPolygonGraphic()
{
Symbol = poly_symbol.MakeSymbolReference(),
Polygon = box
};
graphic.Name = "ExtentSelection";
displayLayer.AddElement(graphic);
It seems that CIMPolygonGraphic constructor overrides Name you set