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?
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?