private void Legend_Refreshed(object sender, Legend.RefreshedEventArgs e) { LayerItemViewModel removeLayerItemVM = null; // If a map layer has sublayers, iterate through them. if (e.LayerItem.LayerItems != null) { // Iterate through all the sublayer items. foreach (LayerItemViewModel layerItemVM in e.LayerItem.LayerItems) { // Collapse all sublayers in the legend. if (layerItemVM.IsExpanded) layerItemVM.IsExpanded = false; // Remove the sublayer named "states" from the legend. The layer remains visible in the map. if (layerItemVM.Label == "states") removeLayerItemVM = layerItemVM; } if (removeLayerItemVM != null) e.LayerItem.LayerItems.Remove(removeLayerItemVM); } else { // Collapse all map layers in the legend. e.LayerItem.IsExpanded = false; } }
private void Legend_Refreshed(object sender, Legend.RefreshedEventArgs e) { if (e.LayerItem.LayerItems != null) foreach (LayerItemViewModel layerItemVM in e.LayerItem.LayerItems) if (layerItemVM.IsExpanded) layerItemVM.IsExpanded = false; }
public override void OnApplyTemplate() { base.OnApplyTemplate(); ConfigureButton = GetTemplateChild(PART_CONFIGUREBUTTON) as Button; if (ConfigureButton != null) ConfigureButton.Click += ConfigureButton_Click; _legend = GetTemplateChild(PART_LEGEND) as Legend; if (Map == null && MapApplication.Current != null) Map = MapApplication.Current.Map; }
/// <summary> /// Refresh legend /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Legend_Refreshed(object sender, Legend.RefreshedEventArgs e) { try { if (e.LayerItem.Layer.GetType() == typeof(FeatureLayer)) { e.LayerItem.IsExpanded = false; } else if (e.LayerItem.Layer.GetType() == typeof(GraphicsLayer)) { this.tocView.LayerLegend.LayerItems.Remove(e.LayerItem); } else { ArcGISMapLayer layer = null; foreach (var item in configuration.GetApplicationConfig().MapConfig.BaseMapLayers) { layer = item.Layers.FirstOrDefault(b => b.Title.Equals(e.LayerItem.Layer.ID)); if (layer != null) break; } if (layer != null && !layer.Expandable) { // Remove the details for the base layers if no details are required if (e.LayerItem.LayerItems != null && e.LayerItem.LayerItems.Count > 0) { e.LayerItem.LayerItems.Clear(); } } else { if (e.LayerItem.LayerItems != null && e.LayerItem.LayerItems.Count > 0) { for (int i = 0; i < e.LayerItem.LayerItems.Count; i++) { e.LayerItem.LayerItems[i].IsExpanded = false; } } } } } catch (Exception ex) { ShowErrorMessagebox.Raise(new Notification { Content = String.Format("Legend_Refreshed-{0}[{1}]", ex.Message, ex.StackTrace), Title = "System error" }); } }
private void Legend_Refreshed(object sender, Legend.RefreshedEventArgs e) { // Clear the sub items from the basemap layer. if (e.LayerItem.Layer == _worldTopographicBasemap) e.LayerItem.LayerItems.Clear(); }