Would there be a straight-forward way to put the SciChart Legend from a LegendModifier inside a WPF Expander control, to show or hide the legend?
Would ScichartSurface need to be subclassed in order to accomplish this visual?
<s:LegendModifier ShowLegend="{Binding ShowLegend}"
Orientation="Vertical"
VerticalAlignment="Center"
HorizontalAlignment="Left"
LegendPlacement ="Right"/>
- Seth Urbach asked 4 years ago
- last edited 4 years ago
-
Hi Seth, Your license is showing as expired – please activate so our forums correct this!
- You must login to post comments
Hi Seth,
You can separate out the generation of the legend data and display of the legend to place it anywhere you want in SciChart WPF.
Have a look at the LegendModifier documentation.
Scroll down to
Alternatively – Binding LegendModifier.LegendData to SciChartLegend
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}"
ShowVisibilityCheckboxes="True" />
Let me know if this helps,
Best regards,
Andrew
- Andrew Burnett-Thompson answered 4 years ago
- You must login to post comments
Thank you Andrew! Your sample code was what I needed and it worked wonderfully! It is very helpful!
Thank you for the reference to the LegendModifier documentation and breaking down the information about binding the LegendModifier.LegendData to a SciChartLegend. That made it very easy to add an Expander in my view and place a SciChartLegend in it.
Regards, Seth Urbach
- Seth Urbach answered 3 years ago
- You must login to post comments
Please login first to submit.