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

Custom legend icon


I would like to create custom legend icons in the legend.
I have multiple series, some of which are for example blue, but differ in the dash style and line width.

I would like to have such line samples in the legend, so that user can see, that a thick, dashed series is for example GDP.
(either by creating my own bitmap image or by any other way possible)

Would that be possible to do in WPF SfChart?

Thanks for the time,


3 Replies

SJ Sumathi Jayaraj Syncfusion Team January 22, 2016 09:35 AM UTC

Hi Paval,

Thanks for contacting Syncfusion support.

SfChart provides the support for customizing legend icons using LegendIconTemplate in chart series. We can define the template as shown in the code sample and bound the values of Stroke, StrokeThickness and StrokeDashArray of the series to the Line’s properties. 

Code Example [XAML]:

<!--Template for legend customization-->

<DataTemplate x:Key="legendIconTemplate">

    <Line X1="0" X2="15" Y1="8" Y2="8" Stroke="{Binding Series.Interior}"

                  StrokeDashArray="{Binding Series.StrokeDashArray}" 

                  StrokeThickness="{Binding Series.StrokeThickness}"/>
<!--Chart series creation-->

<chart:FastLineSeries StrokeThickness="8" XBindingPath="XData" YBindingPath="YData"

                      ItemsSource="{Binding Datas}" Label="Series1" 

                      StrokeDashArray="2,2" Interior="Blue" 
                      LegendIconTemplate="{StaticResource legendIconTemplate}"/>

Output Image:


We have prepared a sample for your requirements and please find the attachment.

Sample: CustomLegend 

Note: For line series, Interior value is assigned to Stroke also default value of Interior is null when its value isn’t explicitly defined.

Sumathi J

PF Pavel Filip January 22, 2016 09:41 AM UTC


this is exactly what we needed,

Thank you!!


SJ Sumathi Jayaraj Syncfusion Team January 22, 2016 11:18 AM UTC

Hi Pavel,

Thanks for your update. Please let us know if you have any queries.

Sumathi J

Live Chat Icon For mobile
Up arrow icon