Select to view content in your preferred language

Legend with two LayerItems Inner Levels

838
1
09-10-2012 06:20 AM
jonataspovoas
Regular Contributor
Hi,

I have the following Legend structure:
[ATTACH=CONFIG]17568[/ATTACH]
<esri:Legend x:Name="legendasDeTematicosDoMapa"
         LayerItemsMode="Tree"
         ShowOnlyVisibleLayers="False"
         Refreshed="Legend_Refreshed" Background="White">
    <esri:Legend.MapLayerTemplate>
        <DataTemplate>
            <StackPanel Orientation="Horizontal">
                <CheckBox IsChecked="{Binding IsEnabled, Mode=TwoWay}"
                          IsEnabled="{Binding IsInScaleRange}"/>
                <Slider Maximum="1" Value="{Binding Layer.Opacity, Mode=TwoWay}" Width="40" Margin="0,0,8,0" />
                <TextBlock Text="{Binding Label}" />
            </StackPanel>
        </DataTemplate>
    </esri:Legend.MapLayerTemplate>
    <esri:Legend.LayerTemplate>
        <DataTemplate>
            <CheckBox Content="{Binding Label}"
                         IsChecked="{Binding IsEnabled, Mode=TwoWay}"
                         IsEnabled="{Binding IsInScaleRange}" />
        </DataTemplate>
    </esri:Legend.LayerTemplate>
</esri:Legend>


I need to change the more internal level of the legend from CheckBoxes into RadioButtons, but when i change the LayerTemplate, the middle checkBoxes change into radioButtons too, which would not be troublesome if i could set them as different radio groups.

does anyone knows the solution to this?
0 Kudos
1 Reply
DominiqueBroux
Esri Frequent Contributor
The legend control supports only 2 built-in levels of customizations : MapLayerTemplate and layerTemplate (3 in fact with LegendItemTemplate).

To add more customozation levels. there are 2 options:
  - if you number of levels is fixed, you can retemplate the legend control and replace the default tree view by imbricated listboxes and/or itemcontrols. Each level can be templated independently. As starting point you can look at this sample
  - if your number of levels is not fixed (i.e in your map service you can have 0, 1 , 2 .. levels of group layers), it's difficult to get rid of the tree view. In this case you can change the Template of the internal level by code (in an handler wired up to event Legend.Refreshed you can set the Template property of the internal level)
0 Kudos