I have a a OxyPlot chart definied in my XAML like this:
<oxy:Plot Height="336">
<oxy:Plot.Series>
<oxy:LineSeries ItemsSource="{Binding Chart}"/>
</oxy:Plot.Series>
</oxy:Plot>
In the viewModel I have the following:
public ObservableCollection<DataPoint> Chart { get; private set; }
public MainViewModel()
{
Chart = new ObservableCollection<DataPoint>()
{ new DataPoint(12, 14), new DataPoint(20, 26) };
public void PriceChange(Model[] quotes)
{
for (int i = 0; i < quotes.Length; i++)
{
Chart.Add(new DataPoint(quotes[i].LastTradePrice, i*10));
}
}
}
I can see the initial graph drawn for the initial two hardcoded DataPoint
s.
But after everything is up and the PriceChange()
method is firing, the new DataPoint
s aren't drawn on the chart. Since it's an ObservableCollection
it should notify the UI automatically, shouldn't it? Or what am I missing?
BTW I have following this example on the documentation.