Click or drag to resize

UniqueValueCollection Class

A collection of UniqueValues
Inheritance Hierarchy
SystemObject
  Esri.ArcGISRuntimeRuntimeCollectionUniqueValue
    Esri.ArcGISRuntimeRuntimeObservableCollectionUniqueValue
      Esri.ArcGISRuntime.SymbologyUniqueValueCollection

Namespace:  Esri.ArcGISRuntime.Symbology
Assembly:  Esri.ArcGISRuntime (in Esri.ArcGISRuntime.dll) Version: 100.11.0
Syntax
public sealed class UniqueValueCollection : RuntimeObservableCollection<UniqueValue>

The UniqueValueCollection type exposes the following members.

Properties
Methods
  NameDescription
Public methodCode exampleAdd
Adds an item to the collection.
(Inherited from RuntimeCollectionT.)
Public methodAddRange (Inherited from RuntimeObservableCollectionT.)
Public methodCode exampleClear
Removes all items from the collection
(Inherited from RuntimeCollectionT.)
Public methodCode exampleContains
Determines whether the collection contains a specific value.
(Inherited from RuntimeCollectionT.)
Public methodCopyTo
Copies the elements of the collection to an Array, starting at a particular Array index.
(Inherited from RuntimeCollectionT.)
Public methodCode exampleGetEnumerator
Returns an enumerator that iterates through the collection.
(Inherited from RuntimeCollectionT.)
Public methodCode exampleIndexOf
Determines the index of a specific item in the collection.
(Inherited from RuntimeCollectionT.)
Public methodCode exampleInsert
Inserts an item to the collection at the specified index.
(Inherited from RuntimeCollectionT.)
Public methodMove
Moves the item at the specified index to a new location in the collection.
(Inherited from RuntimeCollectionT.)
Public methodCode exampleRemove
Removes the first occurrence of a specific object from the collection
(Inherited from RuntimeCollectionT.)
Public methodCode exampleRemoveAt
Removes the item at the specified index.
(Inherited from RuntimeCollectionT.)
Top
Events
Examples

WPF

Example Name: RenderUniqueValues

Render features in a layer using a distinct symbol for each unique attribute value.

Code example screen shot.

C#
// Copyright 2016 Esri.
// 
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an 
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 
// language governing permissions and limitations under the License.

using Esri.ArcGISRuntime.Data;
using Esri.ArcGISRuntime.Mapping;
using Esri.ArcGISRuntime.Symbology;
using System;
using System.Drawing;

namespace ArcGISRuntime.WPF.Samples.RenderUniqueValues
{
    [ArcGISRuntime.Samples.Shared.Attributes.Sample(
        name: "Unique value renderer",
        category: "Symbology",
        description: "Render features in a layer using a distinct symbol for each unique attribute value.",
        instructions: "The map with the symbolized feature layer will be shown automatically when the sample loads.",
        tags: new[] { "draw", "renderer", "symbol", "symbology", "values" })]
    public partial class RenderUniqueValues
    {
        public RenderUniqueValues()
        {
            InitializeComponent();

            // Initialize the sample.
            Initialize();
        }

        private void Initialize()
        {
            // Create new Map with basemap.
            Map myMap = new Map(BasemapStyle.ArcGISTopographic);

            // Create URL to the census feature service.
            Uri serviceUri = new Uri(
                "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/3");

            // Create service feature table.
            ServiceFeatureTable statesFeatureTable = new ServiceFeatureTable(serviceUri);

            // Create a new feature layer using the service feature table.
            FeatureLayer statesLayer = new FeatureLayer(statesFeatureTable);

            // Create a new unique value renderer.
            UniqueValueRenderer regionRenderer = new UniqueValueRenderer();

            // Add the "SUB_REGION" field to the renderer.
            regionRenderer.FieldNames.Add("SUB_REGION");

            // Define a line symbol to use for the region fill symbols.
            SimpleLineSymbol stateOutlineSymbol = new SimpleLineSymbol(
                SimpleLineSymbolStyle.Solid, Color.White, 0.7);

            // Define distinct fill symbols for a few regions (use the same outline symbol).
            SimpleFillSymbol pacificFillSymbol = new SimpleFillSymbol(
                SimpleFillSymbolStyle.Solid, Color.Blue, stateOutlineSymbol);
            SimpleFillSymbol mountainFillSymbol = new SimpleFillSymbol(
                SimpleFillSymbolStyle.Solid, Color.LawnGreen, stateOutlineSymbol);
            SimpleFillSymbol westSouthCentralFillSymbol = new SimpleFillSymbol(
                SimpleFillSymbolStyle.Solid, Color.SandyBrown, stateOutlineSymbol);

            // Add values to the renderer: define the label, description, symbol, and attribute value for each.
            regionRenderer.UniqueValues.Add(
                new UniqueValue("Pacific", "Pacific Region", pacificFillSymbol, "Pacific"));
            regionRenderer.UniqueValues.Add(
                new UniqueValue("Mountain", "Rocky Mountain Region", mountainFillSymbol, "Mountain"));
            regionRenderer.UniqueValues.Add(
                new UniqueValue("West South Central", "West South Central Region", westSouthCentralFillSymbol, "West South Central"));

            // Set the default region fill symbol for regions not explicitly defined in the renderer.
            SimpleFillSymbol defaultFillSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.Cross, Color.Gray, null);
            regionRenderer.DefaultSymbol = defaultFillSymbol;
            regionRenderer.DefaultLabel = "Other";

            // Apply the unique value renderer to the states layer.
            statesLayer.Renderer = regionRenderer;

            // Add created layer to the map.
            myMap.OperationalLayers.Add(statesLayer);

            // Assign the map to the MapView.
            MyMapView.Map = myMap;
        }
    }
}
XAML
<UserControl x:Class="ArcGISRuntime.WPF.Samples.RenderUniqueValues.RenderUniqueValues"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <Grid>
        <esri:MapView x:Name="MyMapView"/>
    </Grid>
</UserControl>
See Also
Additional Examples
Hyperlink to ExampleDescription
RenderUniqueValuesRender features in a layer using a distinct symbol for each unique attribute value.