// (c) Copyright Microsoft Corporation. // This source is subject to the Microsoft Public License (Ms-PL). // Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details. // All other rights reserved. using System.Collections.ObjectModel; namespace System.Windows.Controls.DataVisualization.Charting { /// /// Represents a control that contains a data series. /// /// Preview public abstract partial class Series : Control, ISeries, IRequireSeriesHost { /// /// The name of the Title property. /// protected const string TitleName = "Title"; #region public ISeriesHost SeriesHost /// /// Gets or sets the parent instance the Series belongs to. /// public ISeriesHost SeriesHost { get { return _seriesHost; } set { ISeriesHost oldValue = _seriesHost; _seriesHost = value; if (oldValue != _seriesHost) { OnSeriesHostPropertyChanged(oldValue, _seriesHost); } } } /// /// Stores the Parent instance the Series belongs to. /// private ISeriesHost _seriesHost; /// /// Called when the value of the SeriesHost property changes. /// /// The value to be replaced. /// The new series host value. protected virtual void OnSeriesHostPropertyChanged(ISeriesHost oldValue, ISeriesHost newValue) { if (newValue != null && oldValue != null) { throw new InvalidOperationException(Properties.Resources.Series_SeriesHost_SeriesHostPropertyNotNull); } } #endregion public ISeriesHost SeriesHost #region public ObservableCollection LegendItems /// /// Gets the legend items to be added to the legend. /// public ObservableCollection LegendItems { get; private set; } #endregion public ObservableCollection LegendItems #region public object Title /// /// Gets or sets the title content of the Series. /// public object Title { get { return GetValue(TitleProperty); } set { SetValue(TitleProperty, value); } } /// /// Identifies the Title dependency property. /// public static readonly DependencyProperty TitleProperty = DependencyProperty.Register( TitleName, typeof(object), typeof(Series), new PropertyMetadata(OnTitleChanged)); /// /// TitleProperty property changed callback. /// /// Series for which the Title changed. /// Event arguments. private static void OnTitleChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) { ((Series)o).OnTitleChanged(e.OldValue, e.NewValue); } /// /// Called when the Title property changes. /// /// The old value of the Title property. /// The new value of the Title property. protected virtual void OnTitleChanged(object oldValue, object newValue) { } #endregion public object Title /// /// Initializes a new instance of the Series class. /// protected Series() { LegendItems = new NoResetObservableCollection(); } } }