<sdk:TabItem Header="Layers" Name="LayersTab" Margin="0,0,0,0"> <Grid> <esri:Legend LayerItemsMode="Tree" x:Name="MyLegend" Map="{Binding ElementName=Map}" LegendItemTemplate="{x:Null}" Refreshed="Legend_Refreshed" LayerIDs="USAID_Layers" ShowOnlyVisibleLayers="false"> <esri:Legend.LayerTemplate> <DataTemplate> <!--Layer Item--> <StackPanel x:Name="checkBoxName" Orientation="Horizontal"> <!-- Two overlapping checkboxes, the second checkbox is grayed when the layer is not visible--> <Grid VerticalAlignment="Center"> <CheckBox IsChecked="{Binding IsEnabled, Mode=TwoWay}" /> <CheckBox IsChecked="{Binding IsEnabled}" IsEnabled="{Binding IsVisible}" IsHitTestVisible="False" /> </Grid> <TextBlock Text="{Binding Label}" Tag="{Binding SubLayerID}" VerticalAlignment="Center" Margin="2,0,0,0" MouseLeftButtonDown="ClickOnLayerName" /> </StackPanel> </DataTemplate> </esri:Legend.LayerTemplate> </esri:Legend> </Grid> </sdk:TabItem>
<sdk:TabItem Header="Legend" Name="LegendTab"> <Grid> <esri:Legend Map="{Binding ElementName=Map}" LayerItemsMode="Tree" LayerIDs="USAID_Layers" ShowOnlyVisibleLayers="True"> </esri:Legend> </Grid> </sdk:TabItem>
You have to redefine the MapLayerTemplate as well as in this sample.MapLayerTemplate is used for all main layers (Featurelayer, ArcGISDynamicMapServiceLayer, KmlLayer, .....)The LayerTemplate is used for the sublayers of a main layer only.If you associate a renderer to your feature layer (used when the graphics are not clustered), the legend should be the concatenation of the renderer and of the flareclusterer.
The feature layer is added but without the checkbox (only the name). Why?
My feature layer is a cluster layer. Its default legend looks like in the attached image.Is it possible to show more detailed legend, not only the FlareClusterer?
<esri:Legend.Template> <ControlTemplate TargetType="esri:Legend" xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls" xmlns:sdk="clr-namespace:System.Windows;assembly=System.Windows.Controls"> <toolkit:TreeView ItemsSource="{Binding LayerItemsSource[0].LayerItemsSource, RelativeSource={RelativeSource TemplatedParent}}" Background="{TemplateBinding Background}" Foreground="{TemplateBinding Foreground}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" > <toolkit:TreeView.ItemTemplate> <sdk:HierarchicalDataTemplate ItemsSource="{Binding LayerItemsSource}" > <ContentPresenter Content="{Binding}" ContentTemplate="{Binding Template}" /> </sdk:HierarchicalDataTemplate> </toolkit:TreeView.ItemTemplate> <toolkit:TreeView.ItemContainerStyle> <Style TargetType="toolkit:TreeViewItem"> <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}"/> <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}"/> </Style> </toolkit:TreeView.ItemContainerStyle> </toolkit:TreeView> </ControlTemplate></esri:Legend.Template>
Issue #1: Look at the attached image. I need the groups : USAID-related, Political/Administrative, Infrastructure, Israel-related to behave like TreeView (i.e. collapse/visible). Only the root element: USAID_Layers is redundant.
Hi Dominique,As to issue #1, I thought to do it in Legend.Refreshed event but I didn't know how to catch the root element in order to remove it.I need to remove it, not to collapse it.As to issue #2, I will check it. Do you have a sample of changing LegendItemTemplate ? I looked at your wonderful site (http://broux.dominique.free.fr/Silverlight/InteractiveSDK/Default.htm#LegendTOC) but couldn't find one.Thanks a lot,Miri
<esri:Legend.LegendItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal" Margin="0,-3"> <TextBlock Text="{Binding Label}" Margin="5,0" VerticalAlignment="Center" MinWidth="80" /> <Image Source="{Binding ImageSource}" HorizontalAlignment="Center" VerticalAlignment="Center" Stretch="None" MinWidth="20" Margin="0,-1" /> </StackPanel> </DataTemplate> </esri:Legend.LegendItemTemplate>
What I was asked is :1. Remove the root element usaid_layers so it will show more data to the left
2. shrink the spaces from one layerItem to another in the legend tab.
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.