Select to view content in your preferred language

Silverlight legend doesn't read grouped values

2733
1
11-16-2011 07:06 AM
AdamFeidt
Occasional Contributor
In my published service, which is using an msd, I have multiple symbol values grouped into one label.  Inside my Silverlight legend the values display individually.  I understand what's happening here because my Rest Services page is rendering on a unique VALUE and shows them each individually, but is there any way to correct this or work around this?
0 Kudos
1 Reply
by Anonymous User
Not applicable
Original User: dbroux

The workaround may be to remove the duplicate legend items (based on the Label)

You can hook up an handler to the Legend refreshed event :
 
private void Legend_Refreshed(object sender, ESRI.ArcGIS.Client.Toolkit.Legend.RefreshedEventArgs e)
{
    var items = e.LayerItem.LegendItems;
    if (e.LayerItem.Layer is FeatureLayer && items != null)
    {
        // Group the items by Label and keep only the first one
        var toRemove = items.GroupBy(item => item.Label).SelectMany(g => g.Skip(1)).ToArray();
        foreach (var item in toRemove)
            items.Remove(item);
    }
}
0 Kudos