This is a migrated thread and some comments may be shown as answers.

Chart Title Dependency Property

1 Answer 67 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 14 Jul 2011, 10:24 PM
I created a user control to display a scatter plot based on some given data. I needed to create dependency properties for the label/max/min of axes, and chart title in order to let the user change the properties while obfuscating the inner workings of the chart. The axes properties worked out fine because they were properties of the ChartArea class. The problem is that the ChartTitle property is a member of the ChartDefaultView class and when I apply the same logic as before with the ChartArea class, it doesn't work. Is there some kind of default value that I need to override or something?

This dependency property for the max value of the X-axis works 100% fine.

        public double XAxisMax
        {
            get { return (double)this.GetValue(XAxisMaxProperty); }
            set { this.SetValue(XAxisMaxProperty, value); }
        }

        public static readonly DependencyProperty XAxisMaxProperty =
            DependencyProperty.Register("XAxisMax", typeof(double), typeof(ScatterChart),
                new UIPropertyMetadata(1.0, new PropertyChangedCallback(XAxisMaxCallback)));

        static void XAxisMaxCallback(DependencyObject obj, DependencyPropertyChangedEventArgs args)
        {
            ScatterChart chart = (ScatterChart)obj;
            chart.ChartArea.AxisX.AutoRange = false;
            chart.ChartArea.AxisX.MaxValue = (double)args.NewValue;
        }

The one for the chart title on the other hand does not work.

        public string ChartTitle
        {
            get { return (string)this.GetValue(ChartTitleProperty); }
            set { this.SetValue(ChartTitleProperty, value); }
        }

        public static readonly DependencyProperty ChartTitleProperty =
            DependencyProperty.Register("ChartTitle", typeof(string), typeof(ScatterChart),
                new UIPropertyMetadata(string.Empty, new PropertyChangedCallback(ChartTitleCallback)));

        static void ChartTitleCallback(DependencyObject obj, DependencyPropertyChangedEventArgs args)
        {
            ScatterChart chart = (ScatterChart)obj;
            chart.DefaultView.ChartTitle.Content = (string)args.NewValue;
        }

Any idea what might be wrong?

1 Answer, 1 is accepted

Sort by
0
Giuseppe
Telerik team
answered on 19 Jul 2011, 12:23 PM
Hi Mike,

Unfortunately we were unable to reproduce the problematic behavior in our local tests. Please review the attached sample application and let us know how can we observe the erroneous issue so we can advise you properly how to proceed.


Best wishes,
Giuseppe
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
Chart
Asked by
Mike
Top achievements
Rank 1
Answers by
Giuseppe
Telerik team
Share this question
or