Hi
You can get your feature layer like this:
var lyr = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().First();
var lyr = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().Where(l => l.Name == "U.S. States (Generalized)").First(); ;
To give you an idea how you could use these code snippets, given below is the entire workflow. If you have a button, you can do the following in your button's OnClick method:
protected override async void OnClick()
{
var lyr = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().First();
await SimpleRendererPolygon(lyr);
}
internal static Task SimpleRendererPolygon(FeatureLayer featureLayer)
{
return QueuedTask.Run(() =>
{
CIMStroke outline = SymbolFactory.Instance.ConstructStroke(
ColorFactory.Instance.BlueRGB, 2.0, SimpleLineStyle.Solid);
CIMPolygonSymbol fillWithOutline = SymbolFactory.Instance.ConstructPolygonSymbol(
ColorFactory.Instance.CreateRGBColor(255, 190, 190), SimpleFillStyle.Solid, outline);
CIMSimpleRenderer renderer = featureLayer.GetRenderer() as CIMSimpleRenderer;
renderer.Symbol = fillWithOutline.MakeSymbolReference();
featureLayer.SetRenderer(renderer);
});
}