//Point Feature layer to convert into graphics
var lyr = MapView.Active?.Map?.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault();
//Graphics layer to store the graphics to
var gl = MapView.Active.Map.GetLayersAsFlattenedList().OfType<ArcGIS.Desktop.Mapping.GraphicsLayer>().FirstOrDefault();
if (lyr == null) return;
QueuedTask.Run(() =>
{
//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
gl.AddElements(listGraphicElements);
});