使用oxyplot
是否可以绑定数据表中的数据?
代码编译,但仍然有例外:
''Oxyplot异常:找不到属性PartValuesId System.Data.DataRowView“。
目前的代码是:
lineSeries1.ItemsSource = dt.DefaultView;
lineSeries1.DataFieldY = "PartValues";
lineSeries1.DataFieldX = "PartValuesId";
grid.Children.Clear();
MyModel.Series.Add(lineSeries1);
Myview.Model = MyModel;
grid.Children.Add(Myview);
Grid.SetRow(Myview, 1);
Datatable看起来如下:
PartValuesId PartIdKey PartValues
6277 16 10
6273 16 12
6269 16 15
...
谢谢!
答案 0 :(得分:2)
让它像这样工作:
var results = from row in dt.AsEnumerable()
select new {
PartValuesId= row.Field<Int32>("PartValuesId"),
PartValues= row.Field<string>("PartValues")
};
lineSeries1.ItemsSource = results;
lineSeries1.DataFieldX = "PartValuesId";
lineSeries1.DataFieldY = "PartValues";