ArcGIS Pro 2.6 API Reference Guide
CreateFeatureLayer(Uri,ILayerContainerEdit,Int32,String,RendererDefinition) Method
Example 

ArcGIS.Desktop.Mapping Namespace > LayerFactory Class > CreateFeatureLayer Method : CreateFeatureLayer(Uri,ILayerContainerEdit,Int32,String,RendererDefinition) Method
An URI represents the path or url to a dataset or .lyrx or .lpkx file.
A map or group layer instance where the Feature Layer will be added
The position of the Feature Layer in the map or group layer. 0 represents the top most position.
(optional) When it is not provided, the default display name gets used e.g. the dataset name or alias. (default value = "")
(optional) Provide a RendererDefinition to create a FeatureLayer with your custom renderer instead of the default renderer that gets generated automatically. (default value = null)
Creates a new Feature Layer instance with the specified path to a dataset and adds it to a container such as a map or a group layer. Optionally you can provide a name and rendererDefinition to override the default display name and renderer respectively. This method must be called on the MCT. Use QueuedTask.Run.
Syntax
Public Overloads Function CreateFeatureLayer( _
   ByVal dataUri As Uri, _
   ByVal mapOrGroupLayer As ILayerContainerEdit, _
   ByVal index As Integer, _
   Optional ByVal layerName As String, _
   Optional ByVal rendererDefinition As RendererDefinition _
) As FeatureLayer

Parameters

dataUri
An URI represents the path or url to a dataset or .lyrx or .lpkx file.
mapOrGroupLayer
A map or group layer instance where the Feature Layer will be added
index
The position of the Feature Layer in the map or group layer. 0 represents the top most position.
layerName
(optional) When it is not provided, the default display name gets used e.g. the dataset name or alias. (default value = "")
rendererDefinition
(optional) Provide a RendererDefinition to create a FeatureLayer with your custom renderer instead of the default renderer that gets generated automatically. (default value = null)

Return Value

Exceptions
ExceptionDescription
This method or property must be called within the lambda passed to QueuedTask.Run.
Remarks

Some sample paths to:

A FeatureClass in a FileGeodatabase C:\Data\MyFileGDB.gdb\Census
A FeatureClass from a SDE C:\Connections\MySDEConnection.sde\Roads
A shape file in a folder \\Machine\SharedFolder\MySpatialData.dbf
A .lyrx or .lpkx file \\Machine\SharedFolder\Fires.lyrx
A feature layer off a map or feature service http://sampleserver6.arcgisonline.com/arcgis/rest/services/NapervilleShelters/FeatureServer/0

Example
FeatureLayer flyr = LayerFactory.Instance.CreateFeatureLayer(new Uri(@"C:\Data\Census.gdb\States"), MapView.Active.Map, 0);
Create a feature layer with class breaks renderer with defaults.
await QueuedTask.Run(() =>
  LayerFactory.Instance.CreateFeatureLayer(
    new Uri(@"c:\data\countydata.gdb\counties"),
    MapView.Active.Map,
    layerName: "Population Density (sq mi) Year 2010",
    rendererDefinition: new GraduatedColorsRendererDefinition("POP10_SQMI")
  )
);
Create a feature layer with class breaks renderer.
string colorBrewerSchemesName = "ColorBrewer Schemes (RGB)";
StyleProjectItem style = Project.Current.GetItems<StyleProjectItem>().First(s => s.Name == colorBrewerSchemesName);
string colorRampName = "Greens (Continuous)";
IList<ColorRampStyleItem> colorRampList = await QueuedTask.Run(() =>
{
    return style.SearchColorRamps(colorRampName);
});
ColorRampStyleItem colorRamp = colorRampList[0];

await QueuedTask.Run(() =>
{
    GraduatedColorsRendererDefinition gcDef = new GraduatedColorsRendererDefinition()
    {
        ClassificationField = "CROP_ACR07",
        ClassificationMethod = ArcGIS.Core.CIM.ClassificationMethod.NaturalBreaks,
        BreakCount = 6,
        ColorRamp = colorRamp.ColorRamp,
        SymbolTemplate = SymbolFactory.Instance.ConstructPolygonSymbol(
                        ColorFactory.Instance.GreenRGB, SimpleFillStyle.Solid, null).MakeSymbolReference(),
        ExclusionClause = "CROP_ACR07 = -99",
        ExclusionSymbol = SymbolFactory.Instance.ConstructPolygonSymbol(
                        ColorFactory.Instance.RedRGB, SimpleFillStyle.Solid, null).MakeSymbolReference(),
        ExclusionLabel = "No yield",
    };

    LayerFactory.Instance.CreateFeatureLayer(new Uri(@"c:\Data\CountyData.gdb\Counties"),
        MapView.Active.Map, layerName: "Crop", rendererDefinition: gcDef);
});
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 7

See Also

Reference

LayerFactory Class
LayerFactory Members
Overload List