SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and now iOS Charting & Android Chart Components
the handlers I’ve attached to my viewmodels (FastLineRenderableSeriesForMvvm) used in a chart do not trigger when I change the Stroke or IsVisible properties via bound controls.
I’m setting up a LineRenderableSeriesViewModel to display the data in my chart. I then attach an event handler to the PropertyChanged event of the series view model. Then, I bind a color picker and a checkbox to the Stroke and IsVisible properties of the view model in the same xaml file that also contains the chart. When I change the color via the color picker or toggle the checkbox the chart is updated accordingly (color/visibility changes), however, the event handler is never notified of the changed property (i.e. a breakpoint on the return statement inside the delegate is never hit)
renderableSeries.Stroke = new LineRenderableSeriesViewModel;
renderableSeries.Stroke = seriesColor;
renderableSeries.StrokeThickness = configuration.Thickness;
renderableSeries.XAxisId = configuration.XAxisId;
renderableSeries.YAxisId = configuration.YAxisId;
renderableSeries.DataSeries = dataSeries;
renderableSeries.StyleKey = configuration.StyleKey;
renderableSeries.IsVisible = configuration.IsVisible;
(o, e) =>
I understand now.
The RenderableSeries should not have PropertyChanged at all – this is probably legacy code that should have long been taken out. It should not fire PropertyChanged when a property changes, because these are dependency properties, you will need to listen to their changes in another way.
1.) via binding
2.) via Dependency Property notifier / watcher class
Have a look at https://stackoverflow.com/a/29946333/303612 for a solution
I don’t mean the RenderableSeries class, I mean LineRenderableSeriesViewModel. “renderableSeries” is the name of the VM in my code. I disassembled this down to BaseSciChartElementViewModel which indeed has a PropertyChanged EventHandler (and needs one because it implements INotifyPropertyChanged).
Here’s my scenario: I have color/visibility controls bound to the Legend of the chart. Using Snoop, when I make changes there, I can see that in the XYSeriesInfo in the Legend the color/visibility changes I make do happen, and they are also made to the FastLineRenderableSeriesForMvvm that the SciChartSurface uses. I can see that they are also made in the LineRenderableSeriesViewModel that is in FastLineRenderableSeriesForMvvm’s DataContext property. So it appears that the source LineRenderableSeriesViewModels are updated correctly but no notification happens.
Due to data separation I cannot bind any of the chart to my backend data aside from providing the LineRenderableSeriesViewModels as a data source. Without INotifyPropertyChanged on LineRenderableSeriesViewModel working as expected it appears my only option is to add a behavior to SciChartSurface that adds a Dependancy property forwarder from FastLineRenderableSeriesForMvvm to it’s underlying LineRenderableSeriesViewModel source whenever a new item is added to SciChartSurface’s RenderableSeries.
Please login first to submit.