modify symbol on legend that is rendered from feature service

08-22-2018 02:23 PM
New Contributor

Hello everyone, 

I'm kind of stuck with how to modify symbol on legend at run time that is rendered from feature service, I'm using a Layer Legend control from UI toolkit and my service is returning same labels and symbols for two items and the legend is showing the symbol twice

And also is there a way to disable selectionMode on Legend items in Legend control from Toolkit?

Tags (2)
0 Kudos
3 Replies
Esri Regular Contributor

Legend will use the same symbology applied to the features so if you set FeatureLayer.Renderer on one of them to differentiate between the two.

For example,

((FeatureLayer)e.Layer).Renderer = new SimpleRenderer(new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Diamond, Color.Blue, 10d)) { Label = "New Label" };

Legend will pick up this new symbol and label. 

What platform are you using?

0 Kudos
New Contributor

Thanks for your reply,

I'm using this in a UWP application.Yes that is what i did to get around the issue.

I created a custom uniqueValue renderer to override the symbology from the service.

var Renderer = new UniqueValueRenderer();
var outlineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.White, 2.0);
var csoSimpleMarker = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, Color.Blue, 12)
Outline = outlineSymbol

But I'm still not able to turn off the selection Mode in the Legend Control.

0 Kudos
Esri Regular Contributor

Thank you, we should fix that in our LayerLegend. I just logged this issue

Meanwhile, you can update the Template style by adding this resource

    <Style TargetType="esriTK:LayerLegend">
        <Setter Property="Template">
                        <ItemsControl x:Name="ItemsList" 
                      ItemTemplate="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ItemTemplate}" 
                      ItemsPanel="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ItemsPanel}" />
0 Kudos