This project is read-only.

Legend.VisibleInLegend does not update legend

Jun 17, 2010 at 10:31 PM
Edited Jun 17, 2010 at 10:37 PM
I have bound this attached property: when the source of the binding changes, the legend is not updated. The following code change was necessary in Legend.xaml.cs: public static readonly DependencyProperty VisibleInLegendProperty = DependencyProperty.RegisterAttached( "VisibleInLegend", typeof(bool), typeof(Legend), new UIPropertyMetadata( false, null, OnVisibleInLegend )); private static object OnVisibleInLegend(DependencyObject dependencyObject, object obj) { ViewportElement2D plotterElement = dependencyObject as ViewportElement2D; if (plotterElement != null) { ChartPlotter chartPlotter = plotterElement.Plotter as ChartPlotter; if (chartPlotter != null && chartPlotter.Legend != null) { if ((bool)obj) { chartPlotter.Legend.RemoveLegendItem(plotterElement.Description.LegendItem); chartPlotter.Legend.AddLegendItem(plotterElement.Description.LegendItem); } else { chartPlotter.Legend.RemoveLegendItem(plotterElement.Description.LegendItem); } } } return obj; }