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.
- Naveen Badal asked 6 years ago
- last edited 6 years ago
- You must login 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: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" />
- Andrew Burnett-Thompson answered 6 years ago
- You must login to post comments
Please login first to submit.