internal RefreshedEventArgs(LayerItemViewModel layerItem, Exception ex) { LayerItem = layerItem; Error = ex; }
/// <summary> /// Invoked whenever application code or internal processes (such as a /// rebuilding layout pass) call ApplyTemplate. In simplest terms, this /// means the method is called just before a UI element displays in your /// app. Override this method to influence the default post-template /// logic of a class. /// </summary> protected override void OnApplyTemplate() { base.OnApplyTemplate(); if (!_isLoaded) { _isLoaded = true; if (Windows.ApplicationModel.DesignMode.DesignModeEnabled && (Layers == null || !Layers.Any())) { if (_legendTree.LayerItems == null) { // Create a basic hierarchy for design : Map Layer -> SubLayer -> LegendItemViewModel var legendItem1 = new LegendItemViewModel { Label = "LegendItem1", Symbol = new SimpleMarkerSymbol { Style = SimpleMarkerStyle.Circle, Color = Colors.Red } }; var legendItem2 = new LegendItemViewModel { Label = "LegendItem2", Symbol = new SimpleMarkerSymbol { Style = SimpleMarkerStyle.Diamond, Color = Colors.Green } }; var layerItem = new LayerItemViewModel { Label = "LayerItem", LegendItems = new ObservableCollection<LegendItemViewModel> { legendItem1, legendItem2 } }; var mapLayerItem = new LayerItemViewModel { Label = "MapLayerItem", LayerType = MapLayerItem.MapLayerType, LayerItems = new ObservableCollection<LayerItemViewModel> { layerItem }, }; _legendTree.LayerItems = new ObservableCollection<LayerItemViewModel> { mapLayerItem }; } } else { // Initialize the Map now that all parameters are well known _legendTree.Layers = Layers; } } }