Showing or Hiding a RenderableSeries
Posted by Admin - on 21 March 2014 11:19 AM
Why Can’t I use Visibility.Collapsed?
As previously mentioned in What is a RenderableSeries, the RenderableSeries “are not truly visual UIElements in the sense that WPF visuals are. The RenderableSeries are included in the Visual Tree so that styling and RelativeSource binding works, however they are not rendered using the WPF composition engine.”
This means if you want to make a RenderableSeries invisible, setting BaseRenderableSeries.Visibility = Visibility.Collapsed will not do it. Instead, you need to use the IsVisible property.
Using the RenderableSeries.IsVisible Property
To toggle the Visibility of a RenderableSeries, use the following code:
Toggling Visibility in Code
var rSeries = new FastLineRenderableSeries(); rSeries.IsVisible = false;
Toggling Visibility in XAML
<s:SciChartSurface.RenderableSeries> <s:FastLineRenderableSeries x:Name="lineSeries" IsVisible="False"/> </s:SciChartSurface.RenderableSeries>
Tip! Note that IsVisible is a DependencyProperty, we use it in many examples to switch the visible RenderableSeries type where 2 or more RenderableSeries are bound to the same DataSeries, to give the visual effect of the RenderableSeries type changing (e.g. changing from Line to Mountain). Also note that RenderableSeries.Visibility bindings have no effect. This is because RenderableSeries are not in the Visual Tree, but rendered using our proprietary high-speed rendering engine.
Setting the SeriesColor to Transparent will mean that line rendering is skipped for this series. This is useful, say if you want to toggle the line on/off in a Line Series with Point-Markers but leave the series on the chart for hit-test or AutoRange computations.