/// <summary> /// Refreshes the legend. /// </summary> public void RefreshLegend() { //if (!isLegendUpdate) //{ if (this.Legend != null) { this.LegendItems.Clear(); if (this.Series != null) { foreach (SeriesBase series in this.Series) { //if (!(series is PieSeriesBase)) //{ var legendItem = new LegendItem { Series = series }; var showIconBinding = new Binding { Path = new PropertyPath("ShowIcon"), Source = this.Legend }; BindingOperations.SetBinding(legendItem, LegendItem.ShowIconProperty, showIconBinding); this.LegendItems.Add(legendItem); //} //else //{ // LegendItems = (series as PieSeriesBase).LegendItems; //} } } this.Legend.ItemsSource = this.LegendItems; _isLegendUpdate = true; switch (this.Legend.LegendPosition) { case LegendPosition.Inside: if (this.OuterChartPanel != null && this.OuterChartPanel.Children.Contains(this.Legend)) { this.OuterChartPanel.Children.Remove(this.Legend); } if (this.InnerChartPanel != null && !this.InnerChartPanel.Children.Contains(this.Legend)) { this.InnerChartPanel.Children.Add(this.Legend); } break; case LegendPosition.Outside: if (this.InnerChartPanel != null && this.InnerChartPanel.Children.Contains(this.Legend)) { this.InnerChartPanel.Children.Remove(this.Legend); } if (this.OuterChartPanel != null && !this.OuterChartPanel.Children.Contains(this.Legend)) { this.OuterChartPanel.Children.Add(this.Legend); } break; } } //} }
/// <summary> /// Refreshes the legend. /// </summary> public void RefreshLegend() { //if (!isLegendUpdate) //{ if (this.Legend != null) { this.LegendItems.Clear(); if(this.Series!=null) foreach (SeriesBase series in this.Series) { //if (!(series is PieSeriesBase)) //{ var legendItem = new LegendItem {Series = series}; var showIconBinding = new Binding { Path = new PropertyPath("ShowIcon"), Source = this.Legend }; BindingOperations.SetBinding(legendItem, LegendItem.ShowIconProperty, showIconBinding); this.LegendItems.Add(legendItem); //} //else //{ // LegendItems = (series as PieSeriesBase).LegendItems; //} } this.Legend.ItemsSource = this.LegendItems; _isLegendUpdate = true; switch (this.Legend.LegendPosition) { case LegendPosition.Inside: if (this.OuterChartPanel != null && this.OuterChartPanel.Children.Contains(this.Legend)) { this.OuterChartPanel.Children.Remove(this.Legend); } if (this.InnerChartPanel != null && !this.InnerChartPanel.Children.Contains(this.Legend)) { this.InnerChartPanel.Children.Add(this.Legend); } break; case LegendPosition.Outside: if (this.InnerChartPanel != null && this.InnerChartPanel.Children.Contains(this.Legend)) { this.InnerChartPanel.Children.Remove(this.Legend); } if (this.OuterChartPanel != null && !this.OuterChartPanel.Children.Contains(this.Legend)) { this.OuterChartPanel.Children.Add(this.Legend); } break; } } //} }