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

Dynamic creation of Point Template

1 Answer 28 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Usama asked on 16 Nov 2020, 09:55 AM

Hi, In telerik For my scatter point data (dynamically created in c#), I want to assign colors to each point dynamically by Point Template 


           var chart = new Telerik.Windows.Controls.RadCartesianChart();

            ScatterPointSeries scatterSeries = new ScatterPointSeries();
            for (int i = 0; i < 100; i++)
                ScatterDataPoint point = new ScatterDataPoint();
                point.XValue = xvaluelist[i];
                point.YValue = yvaluelist[i];

                Brush color = new SolidColorBrush(colorlist[i]);

              DataTemplate datatemplate = new DataTemplate(typeof(Ellipse));
              FrameworkElementFactory element= new FrameworkElementFactory(typeof(Ellipse));
              element.SetValue(,);   //Issue is here
              datatemplate.VisualTree = element;




element.SetValue accept two inputs that are dependencyproperty dp, object value


What should be dependency property and object value in this case so that I could assign colors to each point as from my color list.

1 Answer, 1 is accepted

Sort by
Martin Ivanov
Telerik team
answered on 18 Nov 2020, 05:49 PM

Hello Usama,

The SetValue() method should assign properties of the Ellipse class because the corresponding FrameworkElementFactory object targets Ellipse. Here is an example:

element.SetValue(Ellipse.FillProperty, Brushes.Red);

You can also check the Using DataTemplate in Code article that shows a couple of alternative approaches for creating dynamic DataTemplates.

Additionally, you can consider an approach with data binding similar to the one shown in the Binding the Color of Series Items article.

Martin Ivanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at

Asked by
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question