Can legenditems (symbology and label) be displayed in a control of other than a legend, I assume so? It seems to work as far as, the first messagebox displays the sublayer name and the second message box shows the label for the unique values in the legend if the layer is visible. So...how can i put the label and its symbology in my columns?
<Style x:Key="WrapPanel" TargetType="esri:Legend"> <Setter Property="LayerItemsMode" Value="Flat" /> <Setter Property="ShowOnlyVisibleLayers" Value="True" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="esri:Legend"> <ListBox x:Name="listBox" ItemsSource="{TemplateBinding LayerItemsSource}" Background="{TemplateBinding Background}" Foreground="{TemplateBinding Foreground}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Disabled" > <ListBox.ItemsPanel> <ItemsPanelTemplate> <Controls:WrapPanel Orientation="Vertical"/> </ItemsPanelTemplate> </ListBox.ItemsPanel> <ListBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Vertical"> <!--Layer Item--> <ContentPresenter Content="{Binding}" ContentTemplate="{Binding Template}" /> <!--Legend Items--> <ItemsControl ItemsSource="{Binding LegendItems}"> <ItemsControl.ItemTemplate> <DataTemplate > <ContentPresenter Content="{Binding}" ContentTemplate="{Binding Template}" /> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox> </ControlTemplate> </Setter.Value> </Setter> </Style>
<local:SelectManyLegendItems x:Key="selectManyLegendItems" /> <Style x:Key="WrapPanelItems" TargetType="esri:Legend"> <Setter Property="LayerItemsMode" Value="Flat" /> <Setter Property="ShowOnlyVisibleLayers" Value="True" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="esri:Legend"> <ListBox x:Name="listBox" ItemsSource="{Binding LayerItemsSource, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource selectManyLegendItems}}" Background="{TemplateBinding Background}" Foreground="{TemplateBinding Foreground}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Disabled" > <ListBox.ItemsPanel> <ItemsPanelTemplate> <Controls:WrapPanel Orientation="Vertical" /> </ItemsPanelTemplate> </ListBox.ItemsPanel> <ListBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Vertical"> <ContentPresenter Content="{Binding}" ContentTemplate="{Binding Template}" /> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox> </ControlTemplate> </Setter.Value> </Setter> </Style>
public sealed class SelectManyLegendItems : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { return (value as IEnumerable<LegendItemViewModel>).OfType<LayerItemViewModel>().SelectMany(layerItem => layerItem.LegendItems); } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw (new Exception(string.Format("Not implemented or Bad usage of {0}", GetType().Name))); } }
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.