我在 xaml 中有这个图表:
<oxy:Plot Name="Plot" Title="Errors" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3">
<oxy:Plot.Axes>
<oxy:LinearAxis Position="Bottom" Minimum="0" Maximum="100" MajorGridlineStyle="Solid" MinorGridlineStyle="Dash" />
<oxy:LinearAxis Position="Left" Minimum="0" Maximum="100" MajorGridlineStyle="Solid" MinorGridlineStyle="Dash" />
</oxy:Plot.Axes>
<oxy:LineSeries ItemsSource="{Binding Foo}" DataFieldX="X" DataFieldY="Y" />
</oxy:Plot>
和 BackgroundWorker 我做了一些魔术:
Dispatcher.BeginInvoke((Action)(() =>
{
Foo.Add(new Point() { X = Foo.Count, Y = 5 });
Plot.RefreshPlot(true);
Debug.WriteLine("Added a point...");
}));
Foo 当然被定义为一个属性:
ObservableCollection<Point> Foo { get; set; }
我在构造函数中初始化它:
public MainWindow()
{
Foo = new ObservableCollection<Point>();
但是仍然没有显示任何点。我的数据绑定应该有效吗?