Just a tip, to be generic you can replace your test 'if (e.LayerItem.Label == "Group ID")' by 'if (e.LayerItem.Layer is GroupLayer)'
Would this be placed in the Legend.MapLayerTemplate?
I accomplished this in the code behind using LINQ to reverse the order:
private void Legend_Refreshed(object sender, Legend.RefreshedEventArgs e) { // Reverse the groups layer items if (e.LayerItem.Label == "Group ID") { e.LayerItem.LayerItems = new System.Collections.ObjectModel.ObservableCollection<LayerItemViewModel>(e.LayerItem.LayerItems.Reverse()); } }
One option is you to write a value converter reversing the list of legend items, and then retempalte the legend control and use this converter.Something like :<sdk:HierarchicalDataTemplate ItemsSource="{Binding LayerItemsSource, Converter=MyReverseConverter}" >...
<esri:Legend Map="{Binding ElementName=MyMap}" LayerItemsMode="Tree" LayerIDs="Bloomfield Hills" ShowOnlyVisibleLayers="False" Refreshed="Legend_Refreshed"> <esri:Legend.MapLayerTemplate> <sdk:HierarchicalDataTemplate ItemsSource="{Binding LayerItemsSource, Converter=MyReverseConverter}" > <StackPanel Orientation="Horizontal"> <CheckBox Content="{Binding Label}" IsChecked="{Binding IsEnabled, Mode=TwoWay}" IsEnabled="{Binding IsInScaleRange}" > </CheckBox> </StackPanel> </sdk:HierarchicalDataTemplate> </esri:Legend.MapLayerTemplate> </esri:Legend>
Los miembros registrados pueden publicar, seguir actualizaciones y más. ¿Nuevo aquí? Regístrate gratis.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.