ArcGIS Pro 3.2 API Reference Guide
ArcGIS.Core.CIM Namespace / CIMUniqueValueClass Class / Patch Property
Example

In This Topic
    Patch Property (CIMUniqueValueClass)
    In This Topic
    Gets or sets the patch.
    Syntax
    public PatchShape Patch {get; set;}
    Public Property Patch As PatchShape
    Example
    Create a UniqueValueRenderer to specify symbols to values
    return QueuedTask.Run(() =>
    {
      //The goal is to construct the CIMUniqueValueRenderer which will be applied to the feature layer.
      // To do this, the following are the objects we need to set the renderer up with the fields and symbols.
      // As a reference, this is the USCities dataset. Snippet will create a unique value renderer that applies 
      // specific symbols to all the cities in California and Alabama.  The rest of the cities will use a default symbol.
    
      // First create a "CIMUniqueValueClass" for the cities in Alabama.
      List<CIMUniqueValue> listUniqueValuesAlabama = new List<CIMUniqueValue> { new CIMUniqueValue { FieldValues = new string[] { "Alabama" } } };
      CIMUniqueValueClass alabamaUniqueValueClass = new CIMUniqueValueClass
      {
        Editable = true,
        Label = "Alabama",
        Patch = PatchShape.Default,
        Symbol = SymbolFactory.Instance.ConstructPointSymbol(ColorFactory.Instance.RedRGB).MakeSymbolReference(),
        Visible = true,
        Values = listUniqueValuesAlabama.ToArray()
    
      };
      // Create a "CIMUniqueValueClass" for the cities in California.
      List<CIMUniqueValue> listUniqueValuescalifornia = new List<CIMUniqueValue> { new CIMUniqueValue { FieldValues = new string[] { "California" } } };
      CIMUniqueValueClass californiaUniqueValueClass = new CIMUniqueValueClass
      {
        Editable = true,
        Label = "California",
        Patch = PatchShape.Default,
        Symbol = SymbolFactory.Instance.ConstructPointSymbol(ColorFactory.Instance.BlueRGB).MakeSymbolReference(),
        Visible = true,
        Values = listUniqueValuescalifornia.ToArray()
      };
      //Create a list of the above two CIMUniqueValueClasses
      List<CIMUniqueValueClass> listUniqueValueClasses = new List<CIMUniqueValueClass>
        {
                      alabamaUniqueValueClass, californiaUniqueValueClass
        };
      //Create a list of CIMUniqueValueGroup
      CIMUniqueValueGroup uvg = new CIMUniqueValueGroup
      {
        Classes = listUniqueValueClasses.ToArray(),
      };
      List<CIMUniqueValueGroup> listUniqueValueGroups = new List<CIMUniqueValueGroup> { uvg };
      //Create the CIMUniqueValueRenderer
      CIMUniqueValueRenderer uvr = new CIMUniqueValueRenderer
      {
        UseDefaultSymbol = true,
        DefaultLabel = "all other values",
        DefaultSymbol = SymbolFactory.Instance.ConstructPointSymbol(ColorFactory.Instance.GreyRGB).MakeSymbolReference(),
        Groups = listUniqueValueGroups.ToArray(),
        Fields = new string[] { "STATE_NAME" }
      };
      //Set the feature layer's renderer.
      featureLayer.SetRenderer(uvr);
    });
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also