Change In/DependentValueBinding in DataPointSeries

May 12, 2010 at 9:53 AM

Change the properties IndependentValueBinding and DependentValueBinding from normal to DependencyProperties.

To be able to use these for templating in FrameworkElementFactories.

Code:

        /// <summary>
        /// Gets or sets the Binding to use for identifying the dependent value.
        /// </summary>
        public Binding DependentValueBinding
        {
            get { return (Binding)GetValue(DependentValueBindingProperty); }
            set { SetValue(DependentValueBindingProperty, value); }
        }

        /// <summary>
        /// Using a DependencyProperty as the backing store for IndependentValueBinding.  This enables animation, styling, binding, etc...
        /// </summary>
        public static readonly DependencyProperty DependentValueBindingProperty =
            DependencyProperty.Register("DependentValueBinding", typeof(Binding), typeof(DataPointSeries), new UIPropertyMetadata(null, new PropertyChangedCallback(OnDependentValueBindingChanged)));

        private static void OnDependentValueBindingChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            DataPointSeries dps = d as DataPointSeries;
            Binding oldValue = e.OldValue as Binding;
            Binding newValue = e.NewValue as Binding;
            dps.OnDependentValueBindingChanged(oldValue, newValue);
        }

        private void OnDependentValueBindingChanged(Binding oldValue, Binding newValue)
        {
            Refresh();
        }

        /// <summary>
        /// Gets or sets the Binding to use for identifying the independent value.
        /// </summary>
        public Binding IndependentValueBinding
        {
            get { return (Binding)GetValue(IndependentValueBindingProperty); }
            set { SetValue(IndependentValueBindingProperty, value); }
        }

        /// <summary>
        ///  Using a DependencyProperty as the backing store for IndependentValueBinding.  This enables animation, styling, binding, etc...
        /// </summary>
        public static readonly DependencyProperty IndependentValueBindingProperty =
            DependencyProperty.Register("IndependentValueBinding", typeof(Binding), typeof(DataPointSeries), new UIPropertyMetadata(null, new PropertyChangedCallback(OnIndependentValueBindingChanged)));

        private static void OnIndependentValueBindingChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            DataPointSeries dps = d as DataPointSeries;
            Binding oldValue = e.OldValue as Binding;
            Binding newValue = e.NewValue as Binding;
            dps.OnIndependentValueBindingChanged(oldValue, newValue);
        }

        private void OnIndependentValueBindingChanged(Binding oldValue, Binding newValue)
        {
            Refresh();
        }