We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How can I set a fast line series to be a a dotted line programattically

I have a an sfChart based on a set of FastLineSeries which are generated programmatically from underlying data in the model. Where a series is the first or last I want a dotted line rather than solid. I've achieved this using FastLineSeries and setting the StrokeDashArray property:-

FastLineSeries series = new FastLineSeries()


Label = ColumnHeaders[col],

ItemsSource = points,

XBindingPath = "Timestamp",

YBindingPath = "Value"


if (mRiskResult is LevelRiskResult

&& (col == ColumnHeaders.Length - 1 //We wan't the min and max to be dashed lines

|| col == 0))

series.StrokeDashArray = new DoubleCollection() { 2, 2 };

This works great but I'm being asked to make the legend display a similar dotted line. I've found this article which explains how to do it in xaml but I can't seem to work out the syntax to do it when creating the series programatically.

Can you let me know how to do this from code?


3 Replies 1 reply marked as answer

NM Nanthini Mahalingam Syncfusion Team April 5, 2023 09:20 AM UTC

Hi Declan Hillier,

We have analyzed your query and would like to inform you that we can display the dashed line legend icon using the LegendIconTemplate. We can draw a polyline with a dashed style using the framework property in the code behind, as shown in the code snippet.


PointCollection points = new PointCollection();

            points.Add(new Point(0, 0));

            points.Add(new Point(8, 0));

            points.Add(new Point(40, 0));


            DataTemplate legendIcon = new DataTemplate();

            FrameworkElementFactory stackpanel = new FrameworkElementFactory(typeof(StackPanel));

            stackpanel.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal);


            stackpanel.SetValue(StackPanel.VerticalAlignmentProperty, VerticalAlignment.Center);


            double thickness = 2;

            FrameworkElementFactory poliElement = new FrameworkElementFactory(typeof(Polyline));

            poliElement.SetValue(Polyline.PointsProperty, points);

            poliElement.SetValue(Polyline.StrokeDashArrayProperty, new DoubleCollection() { 1, 1 });

            poliElement.SetValue(Polyline.StrokeProperty, new SolidColorBrush(Colors.Blue));

            poliElement.SetValue(Polyline.StrokeThicknessProperty,thickness );



            legendIcon.VisualTree = stackpanel;


FastLineSeries fastLineSeries = new FastLineSeries()


                Name = "series",

                ItemsSource = vm.AccountData,

                XBindingPath = "Date",

                YBindingPath = "YValue",

                StrokeDashArray = new DoubleCollection() { 3, 2 },

                Stroke = new SolidColorBrush(Colors.Blue),

                StrokeThickness = 1,

                LegendIconTemplate = legendIcon,

                Label = "Fast Chart"



Chart, line chart

Description automatically generated

Please refer to the following documentation:



Please let us know if you need further assistance.


Nanthini Mahalingam.

Attachment: F181582_7a851afe.zip

Marked as answer

DH Declan Hillier April 6, 2023 09:04 AM UTC

Awesome, this worked.  Thank you.

SS Sowndharya Selladurai Syncfusion Team April 7, 2023 06:29 AM UTC

Hi Declan Hillier,

We are glad to know that the reported problem has been resolved. Please let us know if you have any further queries on this. We are happy to help.


Sowndharya Selladurai.

Live Chat Icon For mobile
Up arrow icon