I do not understand ObservableValue, or what is the difference between passing in an ObservableValue and passing in the original value/type itself?
If I take the following as an example, be it ObservableValue or a double type, the Chart would dynamically populate the random value and update the chart including the animation.
So why ObservableValue? And could someone suggest an example.
Values = new ChartValues<ObservableValue>
{
new ObservableValue(r.Next(10, 400)),
};
Values = new ChartValues<double>
{
(r.Next(10, 400)),
};
If you intend to update an individual value within the Values
collection dynamically at runtime after you have populated the initial collection and displayed the chart, you need to use ObservableValue
for the chart to be able to notify this update and update itself accordingly.
There is no event raised when you simply replace a double
value in the collection like this:
Values[0] = 1.0;
...but if you set the Value
property of an ObservableValue
like this, a PropertyChanged
event is raised:
Values[0].Value = 1.0;
The chart subscribes to the PropertyChanged
event to listen for updates. That's the difference.