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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Custom legend icon

Thread ID:





121746 Jan 21,2016 01:06 PM UTC Jan 22,2016 11:18 AM UTC WPF 3
Tags: SfChart
Pavel Filip
Asked On January 21, 2016 01:06 PM UTC


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,


Sumathi Jayaraj [Syncfusion]
Replied On 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

Pavel Filip
Replied On January 22, 2016 09:41 AM UTC


this is exactly what we needed,

Thank you!!


Sumathi Jayaraj [Syncfusion]
Replied On January 22, 2016 11:18 AM UTC

Hi Pavel,

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

Sumathi J


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon