private void UpdateMapLayerItemsRecursive(ObservableCollection <LayerItemViewModel> mapLayerItems, IEnumerable <Layer> layers) { foreach (Layer layer in layers.Where(l => l.ShowLegend)) { MapLayerItem mapLayerItem = FindMapLayerItem(layer); if (mapLayerItem == null) // else reuse existing map layer item to avoid query again the legend and to keep the current state (selected, expansed, ..) { // Create a new map layer item mapLayerItem = new MapLayerItem(layer) { LegendTree = this }; mapLayerItem.Refresh(); } mapLayerItems.Add(mapLayerItem); if (layer is GroupLayer) { UpdateMapLayerItemsRecursive(mapLayerItems, (layer as GroupLayer).ChildLayers); } } }
private void UpdateMapLayerItemsRecursive(ObservableCollection<LayerItemViewModel> mapLayerItems, IEnumerable<Layer> layers) { foreach (Layer layer in layers.Where(l => l.ShowLegend)) { MapLayerItem mapLayerItem = FindMapLayerItem(layer); if (mapLayerItem == null) // else reuse existing map layer item to avoid query again the legend and to keep the current state (selected, expansed, ..) { // Create a new map layer item mapLayerItem = new MapLayerItem(layer) { LegendTree = this }; mapLayerItem.Refresh(); } mapLayerItems.Add(mapLayerItem); if(layer is GroupLayer) UpdateMapLayerItemsRecursive(mapLayerItems, (layer as GroupLayer).ChildLayers); } }