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

1
0

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"
            ScrollViewer.HorizontalScrollBarVisibility="Auto"
            ScrollViewer.VerticalScrollBarVisibility="Auto"
            LegendData="{Binding LegendData.SeriesInfo, ElementName=legendModifierTimeChart, Mode=OneWay,UpdateSourceTrigger=PropertyChanged}"
            ShowVisibilityCheckboxes="True"   IsHitTestVisible="True"  />
    </Border>
</s:CustomAnnotation>

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.

Version
5.1.0.11299
  • You must to post comments
0
0

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:SciChartSurface.ChartModifier>
        <s:ModifierGroup>
            <s:LegendModifier x:Name="legendModifier" GetLegendDataFor="AllSeries" ShowLegend="False"/>
        </s:ModifierGroup>
    </s:SciChartSurface.ChartModifier>

</s:SciChartSurface>

<!-- Somewhere else in your application, you can declare a SciChartLegend and bind to LegendModifier.LegendData -->
<s:SciChartLegend x:Name="legendControl"
   s:ThemeManager.Theme="Chrome"
   Margin="23,23"
   ScrollViewer.HorizontalScrollBarVisibility="Auto"
   ScrollViewer.VerticalScrollBarVisibility="Auto"
   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.