Chart Title Dependency Property

2 posts, 0 answers
  1. Mike
    Mike avatar
    1 posts
    Member since:
    Jun 2011

    Posted 14 Jul 2011 Link to this post

    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?
  2. Giuseppe
    Giuseppe avatar
    2363 posts

    Posted 19 Jul 2011 Link to this post

    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,
    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!

  3. DevCraft R3 2016 release webinar banner
Back to Top