Is it possible to do UniqueValueRenderer with 2 value fields

4492
1
01-12-2015 05:51 PM
MattMiley
Occasional Contributor

I want to define symbology based on values from two attribute fields, Is this possible since it asks for an observable collection of fields??

I tried something similair to below with no luck..


// create new UniqueValueInfos: provide attribute value (food type) and symbol to use
var info1 = new Esri.ArcGISRuntime.Symbology.UniqueValueInfo("Chinese", chineseSym);
var info2 = new Esri.ArcGISRuntime.Symbology.UniqueValueInfo("American", americanSym);
var info3 = new Esri.ArcGISRuntime.Symbology.UniqueValueInfo("Italian", italianSym);


var info3 = new Esri.ArcGISRuntime.Symbology.UniqueValueInfo("8.5", circleSym);


// create a UniqueValueCollection and add the unique value infos
var uniqueInfos = new Esri.ArcGISRuntime.Symbology.UniqueValueInfoCollection();
uniqueInfos.Add(info1);
uniqueInfos.Add(info2);
uniqueInfos.Add(info3);

// create a UniqueValueRenderer: specify the attribute field to render with ("FoodStyle")
var uniqueRenderer = new Esri.ArcGISRuntime.Symbology.UniqueValueRenderer();
uniqueRenderer.Fields = new System.Collections.ObjectModel.ObservableCollection<string>(new[] { "FoodStyle" , "Rating"});

Tags (1)
0 Kudos
1 Reply
DominiqueBroux
Esri Frequent Contributor

You have to initialize the Values with an observable collection of values that match with your observable collection of fields (i.e you have to define the symbol for each combination of FoodStyle and Rating)

Something like:

var info1 = new Esri.ArcGISRuntime.Symbology.UniqueValueInfo();

info1.Symbol = chineseRating8Sym;

info1.Values = new System.Collections.ObjectModel.ObservableCollection<object>(new object[] { "Chinese" , 8.0});

Note that you can't use the UniqueValueInfo constructor to initialize the values collection (I agree it's weird)