{
//Point Feature layer to convert into graphics
var lyr = MapView.Active?.Map?.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault(s => s.ShapeType == esriGeometryType.esriGeometryPoint);
if (lyr == null) return;
// Note: must be called on the QueuedTask
{
//Point symbol for graphics
var pointSymbol = SymbolFactory.Instance.ConstructPointSymbol(CIMColor.CreateRGBColor(100, 255, 40), 10, SimpleMarkerStyle.Circle);
//Collection to hold the point graphics
var listGraphicElements = new List<CIMGraphic>();
//Iterate through each point feature in the feature layer
using (RowCursor rows = lyr.Search()) //execute
{
int i = 0;
while (rows.MoveNext())
{
using var feature = rows.Current as Feature;
//Create a point graphic for the feature
var crimePt = feature.GetShape() as MapPoint;
if (crimePt != null)
{
var cimGraphicElement = new CIMPointGraphic
{
Location = crimePt, //MapPoint
Symbol = pointSymbol.MakeSymbolReference()
};
//Add the point feature to the collection
listGraphicElements.Add(cimGraphicElement);
i++;
}
}
}
//Magic happens...Add all the features to the Graphics layer
graphicsLayer.AddElements(listGraphicElements);
}
}