ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / UniqueValueRendererDefinition Class / UniqueValueRendererDefinition Constructor / UniqueValueRendererDefinition Constructor(List<String>,CIMSymbolReference,CIMColorRamp,CIMSymbolReference,Boolean)
One or more fields be used to get unique values or combination of values from.
A symbol that will be used to draw features whose values are not found in values list.
A color ramp be used to pick color for symbols from.
A symbol that will be used to draw features whose values are not found in values list.
A boolean indicates whether the DefaultSymbol will be used to draw features whose values are not found in the values list or not.
Example

In This Topic
    UniqueValueRendererDefinition Constructor(List<String>,CIMSymbolReference,CIMColorRamp,CIMSymbolReference,Boolean)
    In This Topic
    Creates a UniqueValueRendererDefinition.
    Syntax
    Public Function New( _
       ByVal fields As List(Of String), _
       Optional ByVal symbolTemplate As CIMSymbolReference, _
       Optional ByVal colorRamp As CIMColorRamp, _
       Optional ByVal defaultSymbol As CIMSymbolReference, _
       Optional ByVal useDefaultSymbol As Boolean _
    )

    Parameters

    fields
    One or more fields be used to get unique values or combination of values from.
    symbolTemplate
    A symbol that will be used to draw features whose values are not found in values list.
    colorRamp
    A color ramp be used to pick color for symbols from.
    defaultSymbol
    A symbol that will be used to draw features whose values are not found in values list.
    useDefaultSymbol
    A boolean indicates whether the DefaultSymbol will be used to draw features whose values are not found in the values list or not.
    Example
    How to apply a color ramp from a style to a feature layer
    public async Task ApplyColorRampAsync(FeatureLayer featureLayer, List<string> fields)
    {
    
        StyleProjectItem style =
            Project.Current.GetItems<StyleProjectItem>()
                .FirstOrDefault(s => s.Name == "ColorBrewer Schemes (RGB)");
        if (style == null) return;
        var colorRampList = await QueuedTask.Run(() => 
                    style.SearchColorRamps("Red-Gray (10 Classes)"));
        if (colorRampList == null || colorRampList.Count == 0) return;
        CIMColorRamp cimColorRamp = null;
        CIMRenderer renderer = null;
        await QueuedTask.Run(() =>
        {
            cimColorRamp = colorRampList[0].ColorRamp;
            var rendererDef = new UniqueValueRendererDefinition(fields, null, cimColorRamp);
            renderer = featureLayer?.CreateRenderer(rendererDef);
            featureLayer?.SetRenderer(renderer);
        });
    
    }
    Set unique value renderer to the selected feature layer of the active map
    await QueuedTask.Run(() =>
    {
      var fields = new List<string> { "Type" }; //field to be used to retrieve unique values
      CIMPointSymbol pointSym = SymbolFactory.Instance.ConstructPointSymbol(
          ColorFactory.Instance.GreenRGB, 16.0, SimpleMarkerStyle.Pushpin);  //constructing a point symbol as a template symbol
      CIMSymbolReference symbolPointTemplate = pointSym.MakeSymbolReference();
    
      //constructing renderer definition for unique value renderer
      UniqueValueRendererDefinition uniqueValueRendererDef =
    new UniqueValueRendererDefinition(fields, symbolPointTemplate);
    
      //creating a unique value renderer
      var flyr = MapView.Active.GetSelectedLayers()[0] as FeatureLayer;
      CIMUniqueValueRenderer uniqueValueRenderer = flyr.CreateRenderer(uniqueValueRendererDef) as CIMUniqueValueRenderer;
    
      //setting the renderer to the feature layer
      flyr.SetRenderer(uniqueValueRenderer);
    });
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also