SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and now iOS Charting & Android Chart Components
We also have a tag=SciChart on Stackoverflow.com where you can earn rep for your questions!
Here’s the situation:
Our app has a viewmodel with an XyDataSeries Property bound to the plot. We’ve overridden DataPointSelectionModifer to allow us to trigger calculations when the selected points are changed. This overridden modifier is not instantiated by nor is it directly aware of the viewmodel; it is referenced only in the view xaml.
When changing between datasets we replace the contents of the XyDataSeries Property. Afterwards we are experiencing NullReferenceExceptions in DataPointSelectionModifier.SelectManyPoints(). This occurs whether we replace the contents of the data series or we set a completely new XyDataSeries object into the property.
It appears that the DataPointSelectionModifier.SelectedPointMarkers collection is no longer properly synced to the plot’s XyDataSeries. The size of the the collections are different and with the original DataSeries being garbage-collected the DataPointInfo.DataPointMetadata references are null. So we attempt to dial in a new selection and the deselection of this orphaned null metadata raises exceptions.
Is there some secret-sauce to keeping these collections in line?
Any and all suggestions are greatly appreciated.
Thank you for reporting this. DataPointSelectionModifier doesn’t handle this case; let me log the issue and we’ll think what can be done.
For now, you could just call Clear() on the SelectedPointMarkers collection, or call DeselectAllPointMarkers() in your custom modifier. Or just re-create it.
As to handling changes of DataSeries, the most straightforward way is to subscribe to the DataSeries.DataSeriesChanged event in your custom modifier. You could subscribe to the RenderableSeriesCollection changes in the Attach() method and in the handler subscribe/unsubscribe to the DataSeries.DataSeriesChanged event for every RenderableSeries.
Hope this helps!
Please login first to submit.