Pre loader

Use WPF Expander Control to Show Legend

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

0
0

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"/>
Version
6
  • Andrew Burnett-Thompson
    Hi Seth, Your license is showing as expired – please activate so our forums correct this!
  • You must to post comments
0
0

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

  • You must to post comments
0
0

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

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies