Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
It seems like most charting controls require the DataSource to be bound to a property that uses their custom data types. For example [LiveCharts] requires the DataSource to be bound to the datatype
LiveCharts.ChartValues<LiveCharts.Defaults.ObservablePoint>


As another example, [SciCharts] require the datatype to be
SciChart.Charting.Model.DataSeries.XyDataSeries<double, double>


if you have a ViewModel that is truly independant of the View I can't use their specific datatypes. But neither of them work with the ObserveableCollection so what is the best way to go about using MVVM with charting controls? I'm assuming they do this for performance improvements so I'm guessing using a converter in the binding to convert between ObservableCollection and their custom datatypes would hurt performance. What is best practice?

Thanks.

What I have tried:

Currently I am just violating the MVVM structure and putting their custom datatypes in my view model.
Posted
Comments
Richard Deeming 7-Jun-18 12:05pm    
The model should be independent of the view. The view model is meant to adapt the model to be used by the view. I don't think it's unreasonable for that to include mapping the source data to the data type required by the view.

But if you really want to keep the VM and the V independent, you'll need to use a value converter to convert the source data to the required type.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900