/// <summary> /// Updates the ISeriesHost legend items collection to reflect changes in any /// of the series legend items collections. /// </summary> /// <param name="sender">The series that had its legend items collection /// change.</param> /// <param name="args">Information about what changes were made to the /// collection.</param> private void OnSeriesLegendItemsChanged(object sender, NotifyCollectionChangedEventArgs args) { ReadOnlyObservableCollection <UIElement> chartLegendItems = LegendItems as ReadOnlyObservableCollection <UIElement>; if (args.OldItems != null) { foreach (UIElement item in args.OldItems) { chartLegendItems.Mutate((items) => items.Remove(item)); } } if (args.NewItems != null) { foreach (UIElement item in args.NewItems) { chartLegendItems.Mutate((items) => items.Add(item)); } } }