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?
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?
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();
Renderer.FieldNames.Add("TYPE");
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.
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
<Grid.Resources>
<Style TargetType="esriTK:LayerLegend">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<ItemsControl x:Name="ItemsList"
ItemTemplate="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ItemTemplate}"
ItemsPanel="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ItemsPanel}" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Grid.Resources>