ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / UniqueValueRendererDefinition Class / UniqueValueRendererDefinition Constructor / UniqueValueRendererDefinition Constructor()
Example

In This Topic
    UniqueValueRendererDefinition Constructor()
    In This Topic
    Creates a UniqueValueRendererDefinition.
    Syntax
    public UniqueValueRendererDefinition()
    Public Function New()
    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);
        });
    
    }
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also