Pre loader

Toggle Select/Deselect All Legend Items

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


I think this is a pretty simple question but i am not sure what i am missing.I have a toggle button on my legend that is intended to allow the users to select all the series or deselect all the series.
the button essentially goes through the Renderable series view models and set the IsSelected to either true or false, this approach however, doesn’t work. I looked at the SelectionModifier and i can see that has a protected DeselectAll method and i am thinking to leverage that to solve this use case.

what is the best solution to accomplish this? isn’t this functionality something that perhaps be standard and could just be turned on?

  • You must to post comments

Hi Joseph,

You’ll need to template the ScIChartLegend to place your button in it.

The ControlTemplate for the SciChartLegend control

The auto-generated SciChartLegend control is simply an ItemsControl. The default Control Template for the SciChartLegend is included below:

<ControlTemplate TargetType="s:SciChartLegend">
      HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
      VerticalAlignment="{TemplateBinding VerticalAlignment}"
      Background="{TemplateBinding Background}"
      BorderBrush="{TemplateBinding BorderBrush}"
      BorderThickness="{TemplateBinding BorderThickness}"
      Padding="{TemplateBinding Padding}">
      <ScrollViewer Common:CompatibleFocus.IsFocusable="False" HorizontalScrollBarVisibility="{Binding (ScrollViewer.HorizontalScrollBarVisibility), RelativeSource={RelativeSource TemplatedParent}}" VerticalScrollBarVisibility="{Binding (ScrollViewer.VerticalScrollBarVisibility), RelativeSource={RelativeSource TemplatedParent}}">
         <ItemsPresenter />

Once you have done that, the button must be bound to a command or behavior to iterate over all RenderableSeriesViewModels and set IsSelected = false.

That’s the only way to do it.

Best regards,

  • You must to post comments

Thanks Andrew but i see what is going on in the code. I templated correctly and everything but i needed to also set the IsVisible flag to accomplish what i wanted. I some how thought that just setting IsSelected would handle the selection and deselection of the lines on the chart and the legend. Once i set the IsSelected as well as the IsVisible everything worked out.

  • Jianping Cai
    thanks, it solves the problem for me.
  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.