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

Toggle Series PointTemplate with CheckBox?

2 Answers 85 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 01 Mar 2012, 10:59 PM
I have a RadCartesianChart in my app and I would like to add a checkbox that would allow me to toggle the PointTemplate on or off for each of the Series in my chart.I tried updating the PointTemplate using the following but the ellipses never appear.

void checkBoxShowDots_Click(object sender, RoutedEventArgs e)
{
    foreach (ScatterLineSeries cs in radCartesianChart1.Series)
    {
        if ((bool)checkBoxShowDots.IsChecked)
        {
                string Text = string.Format(
                    "<Ellipse Height=\"6\" Width=\"6\" Fill=\"{0}\" />"
                        , (cs.Stroke as SolidColorBrush).Color.ToString()
                    );
                cs.PointTemplate = CreateDataTemplate(Text);
        }
        else
        {
            cs.PointTemplate = null;
        }
        cs.InvalidateMeasure();
    }
}

How can I achieve this behavior?

2 Answers, 1 is accepted

Sort by
0
Andrew
Top achievements
Rank 1
answered on 05 Mar 2012, 04:06 PM
Update:
I figured out how to do this. I had to create a UIHelper object which implements INotifyPropertyChanged and has a PointTemplate property. I then added a binding to the LineSeries to bind to this property. My Click handler then just goes and then sets the PointTemplate for each UIHelper object.

However....

It seems that if you start off with a null value for the PointTemplate property of the LineSeries, if you try to then assign a new value to that property after the chart has been rendered the new PointTemplate change is never registered. But if I start off with a value for PointTemplate, I can switch back and forth between that and a null value and the points will appear/disappear as expected. I worked around this by defining a PointTemplate that doesn't actually display anything instead of using a null value.

Seems like a bug or at least behavior that should be documented. 
0
Sia
Telerik team
answered on 06 Mar 2012, 04:51 PM
Hello Andrew,

Thank you for the provided feedback. We will check the issue locally and let you know what causes it.

Kind regards,
Sia
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
ChartView
Asked by
Andrew
Top achievements
Rank 1
Answers by
Andrew
Top achievements
Rank 1
Sia
Telerik team
Share this question
or