简体   繁体   English

wp7 ObservableCollection人口

[英]wp7 ObservableCollection population

I'm using the AMCharts control and I'm trying to follow the example however, I'm not sure how I get the data out of my historyItemCollection (fig 1) into an Observable collection (fig 2)? 我正在使用AMCharts控件,但我尝试按照该示例进行操作,但是我不确定如何将我的historyItemCollection(图1)中的数据获取到Observable集合(图2)中?

Fig 1: 图。1:

from item in App.ViewModel.historyItemCollection
where item.VehicleId == (Application.Current as App).vehicleId
select item;

Fig 2: 图2:

private ObservableCollection<TestDataItem> _data = new ObservableCollection<TestDataItem>()
{
    new TestDataItem() { axis = "Mar", value=5},
    new TestDataItem() { axis = "Apr", value=15.2},
    new TestDataItem() { axis = "May", value=25},
    new TestDataItem() { axis = "June", value=8.1},
};

In the historyitemcollection I have a date item that I would put in the axis value as well as a cost item that I would put in the value value (fig 2:) 在historyitemcollection中,我有一个要放入轴值的日期项以及一个要放入值值的成本项(图2 :)

How can I get my data into the observableCollection so I can use this chart control? 如何将数据放入observableCollection中,以便可以使用此图表控件?

_data = new ObservableCollection<HistoryItem>
(
    from item in App.ViewModel.historyItemCollection
    where item.VehicleId == (Application.Current as App).vehicleId
    select item;
)

or if at runtime 或者在运行时

var historyItems =
    from item in App.ViewModel.historyItemCollection
    where item.VehicleId == (Application.Current as App).vehicleId
    select item;

foreach (var item in historyItems)
    _data.Add(item);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM