ArcGIS Pro 3.1 API Reference Guide
ArcGIS.Core.CIM Namespace / CIMUniqueValueRenderer Class / ValueExpressionInfo Property
Example

In This Topic
    ValueExpressionInfo Property (CIMUniqueValueRenderer)
    In This Topic
    Gets or sets ExpressionInfo that contains the Arcade expression that returns value as a string. When both Fields and ValueExpressionInfo are present ValueExpressionInfo is used.
    Syntax
    public CIMExpressionInfo ValueExpressionInfo {get; set;}
    Public Property ValueExpressionInfo As CIMExpressionInfo
    Example
    Modify renderer using Arcade
    var lyr = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault(f => f.ShapeType == esriGeometryType.esriGeometryPolygon);
    if (lyr == null) return;
    QueuedTask.Run(() =>
    {
      // GetRenderer from Layer (assumes it is a unique value renderer)
      var uvRenderer = lyr.GetRenderer() as CIMUniqueValueRenderer;
      if (uvRenderer == null) return;
      //layer has STATE_NAME field
      //community sample Data\Admin\AdminSample.aprx
      string expression = "if ($view.scale > 21000000) { return $feature.STATE_NAME } else { return 'All' }";
      CIMExpressionInfo updatedExpressionInfo = new CIMExpressionInfo
      {
        Expression = expression,
        Title = "Custom" // can be any string used for UI purpose.
      };
      //set the renderer's expression
      uvRenderer.ValueExpressionInfo = updatedExpressionInfo;
    
      //SetRenderer on Layer
      lyr.SetRenderer(uvRenderer);
    });
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.0 or higher.
    See Also