SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and now iOS Charting & Android Chart Components

Welcome to the SciChart Community Forums!

Please use the forums below to ask questions about SciChart. Take a moment to read our Question asking guidelines on how to ask a good question and our support policy. We also have a tag=SciChart on where you can earn rep for your questions!

Please note: SciChart team will only answer questions from customers with active support subscriptions. Expired support questions will be ignored. If your support status shows incorrectly, contact us and we will be glad to help.


I would like to allow user click on Legend and highlight the corresponding Series on the chart but I don’t know if this feature is supported or not.

I tried to add mouse events to the Legend Modified but it seems like mouse events are not triggered

This is the simple code that I am using

<s:LegendModifier x:Name="chlLegend" ShowLegend="True" LegendPlacement="Top" Orientation="Horizontal" MouseDown="chlLegend_MouseDown" ScrollViewer.HorizontalScrollBarVisibility="Auto" />

Before investigating more I would like to ask you if you have any hints which is the correct way to implement this behavior.
Is the LegendModifier suitable for this or should I override instead the Legend Control Template?

Thank you in advance for the support

  • You must to post comments
Best Answer

Yes the property you want to change is BaseRenderableSeries.LegendMarkerTemplate

Here is the default for line:

<DataTemplate x:Key="DefaultLegendMarkerTemplate" DataType="r:BaseRenderableSeries">
    <Line VerticalAlignment="Center"
          Stroke="{Binding SeriesColor,
                           Converter={StaticResource ColorToBrushConverter}}"
          Y2="0.5" />

and for Scatter:

<DataTemplate x:Key="ScatterSeriesLegendMarkerTemplate" DataType="r:XyScatterRenderableSeries">
        <Viewbox HorizontalAlignment="Center" Stretch="Uniform">
            <r:TemplatableControl Template="{Binding PointMarker.PointMarkerTemplate}" />

and for Mountain:

<DataTemplate x:Key="MountainSeriesLegendMarkerTemplate" DataType="r:FastMountainRenderableSeries">
    <Border BorderBrush="{Binding SeriesColor, Converter={StaticResource ColorToBrushConverter}}" BorderThickness="{Binding StrokeThickness, Converter={StaticResource DoubleToThicknessConverter}}">
        <Rectangle Fill="{Binding AreaBrush}" Stretch="Fill" />

I suggest binding something in there to BaseRenderableSeries.StrokeThickness.

Was there anything else you needed to know?

  • You must to post comments

Hi Marco,

Take a look at our tutorial on Custom Legend with Color Picker and Custom Point Markers. This shows you how to proide a LegendItemTemplate with a number of options.

Each Row in the Legend binds to a SeriesInfo derived type. SeriesInfo lets you access the RenderableSeries that the legend row represents.

So, using the above tutorial, you should be able to modify the template to have a checkbox to manipulate SeriesInfo.RenderableSeries.IsVisible.

Let me know if this helps!

Best regards,

  • You must to post comments

Thank you Andrew the link was helpful, I ovveride the default template and added a MouseEvent on the PointMarker that I can use to change the Stroke property of linked RenderableSeries.

                            <s:PointMarker Margin="5,0,0,0"
                                       DataContext="{Binding RenderableSeries}"
                                       DeferredContent="{Binding LegendMarkerTemplate}"
                                       Visibility="{Binding ShowSeriesMarkers, RelativeSource={RelativeSource AncestorType=s:SciChartLegend}, Converter={StaticResource BooleanToVisibilityConverter}}" />

What I did not understand yet is how to increase the thickness also on the line in the Legend.

Can you please share the PointMarker default WPF template so that I can override also that?
I don’t want to add or change the point marker but only increase the thickness of the line. (screenshot)

Thank you in advance.

  • You must to post comments

Thank you Andrew for the support all clear now.

  • You must to post comments
Showing 4 results
Your Answer

Please first to submit.