This example demonstrates how you can provide each legend item with a check box, which controls the visibility of the corresponding series in the unbound mode.
Note that starting with the DXperience version 13.2.1, the chart control supports a built-in check box in the Legend feature. For more details, see the Legend Check Box topic.
Implementation details for the DXperience v2012 vol 2.5
To accomplish this, it is necessary to assign the Legend.Template property to custom template and then bind the ItemsSource property of the ItemsControl object to SeriesNonVisualWrappersCollection.
This custom collection is synchronized with the diagram's series collection when the SeriesCollection.CollectionChanged event fires.
In addition, the fake series is created to avoid hiding the legend when the Series.Visible property is set to false for all series.
See also:
- How to display custom information in the legend;
- How to customize chart titles;
- How to display check boxes for legend items, to control the visibility of series in the bound mode.
Question Comments
Added By: Zeljko Ilic at: 11/17/2014 6:57:42 AM
This is working great - there is just one thing: there is no color on clickable chart legend.
Since each check item corresponds to one curve, ideally they should be having the same color.
Can this be added?
In the latest version (v14.1), this functionality is supported out of the box (see the Legend Check Box article). Please upgrade your application to a more recent version and let me know if you need any clarification.