ArcGIS Pro 3.2 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / UniqueValueRendererDefinition Class
Members Example

In This Topic
    UniqueValueRendererDefinition Class
    In This Topic
    Represents unique value renderer definition to apply a different symbol to each category of feature within the layer based on one or more fields.
    Object Model
    UniqueValueRendererDefinition ClassCIMColorRamp ClassCIMSymbolReference ClassCIMSymbolReference Class
    Syntax
    public class UniqueValueRendererDefinition : RendererDefinition 
    Public Class UniqueValueRendererDefinition 
       Inherits RendererDefinition
    Remarks
    UniqueValueRendererDefinition class allows you to define parameters to create renderers to draw features based on unique values.
    Once you define a unique value renderer, you can call a FeatureLayer's CreateRenderer and SetRenderer methods to create and assign a renderer to a feature layer.
    Example
    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);
    });
    Defining a unique value renderer definition
    var uvrDef = new UniqueValueRendererDefinition()
    {
      ValueFields = new List<string> { "ACTYPE" },
      SymbolTemplate = SymbolFactory.Instance.ConstructPointSymbol(
        ColorFactory.Instance.RedRGB, 10, SimpleMarkerStyle.Hexagon)
          .MakeSymbolReference(),
      ValuesLimit = 5
    };
    //Note: CreateRenderer can only create value classes based on
    //the current events it has received
    streamLayer.SetRenderer(streamLayer.CreateRenderer(uvrDef));
    
    Inheritance Hierarchy

    System.Object
       ArcGIS.Desktop.Mapping.LayerDrawingDefinition
          ArcGIS.Desktop.Mapping.RendererDefinition
             ArcGIS.Desktop.Mapping.UniqueValueRendererDefinition

    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also