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


I created a custom annotation. In the custom annotation, I made a SciChartLegend and bind its Legend Data to LegendData of legendmodifier and also give the element name of it. But the problem I am facing is it is not updating the series info in the SciChartLegend when I am adding the series dynamically. But as I am using the VS 2017, I can change the code in xaml in runtime. So when I change the binding mode of legenddata like earlier it has Mode = OneWay, Now I delete the OneWay and type again the OneWay, now everything works fine. But on the first time, like on no change in the xaml , it is not updating the series info.

Here is my code for Legend Modifier :

 <s:LegendModifier x:Name="legendModifierTimeChart" ShowLegend="True" Orientation="Vertical" Margin="10"
                   LegendPlacement="Right" GetLegendDataFor="AllSeries" Focusable="True"
                   ShowVisibilityCheckboxes="True" ScrollViewer.VerticalScrollBarVisibility="Auto"
                   ScrollViewer.CanContentScroll="True" ShowSeriesMarkers="True"/>

Here is my code for Custom Annotation SciChartLegend:

<s:CustomAnnotation X1="0" Y1="0" CoordinateMode="Relative" IsEditable="True">
    <Border BorderThickness="3" BorderBrush="LightGray" Margin="10">
        <s:SciChartLegend x:Name="legendControl1"
            LegendData="{Binding LegendData.SeriesInfo, ElementName=legendModifierTimeChart, Mode=OneWay,UpdateSourceTrigger=PropertyChanged}"
            ShowVisibilityCheckboxes="True"   IsHitTestVisible="True"  />

It not works until I change the Mode on runtime, Like It already has written OneWay, but on runtime if I delete that and again write

OneWay, everything works fine.

Please help me in solving this issue. It is a humble request.

  • You must to post comments

I think you need to bind to LegendData, not to LegendData.SeriesInfo.

See our SciChartLegend documentation for more details.

You can alternatively bind LegendModifier.LegendData to a SciChartLegend and place anywhere in your application. You can also bind to an LegendModifier.LegendData to an ItemsControl.ItemsSource and template it as you wish.

<s:SciChartSurface x:Name="sciChart" s:ThemeManager.Theme="Chrome">

    <!-- XAxis, YAxis, Omitted for brevity -->

    <!--  Declare ChartModifiers  -->
            <s:LegendModifier x:Name="legendModifier" GetLegendDataFor="AllSeries" ShowLegend="False"/>


<!-- Somewhere else in your application, you can declare a SciChartLegend and bind to LegendModifier.LegendData -->
<s:SciChartLegend x:Name="legendControl"
   LegendData="{Binding LegendData, ElementName=legendModifier, Mode=OneWay}" << NOTE BINDING HERE 
   ShowVisibilityCheckboxes="True" />
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.