簡體   English   中英

wp7 ObservableCollection人口

[英]wp7 ObservableCollection population

我正在使用AMCharts控件,但我嘗試按照該示例進行操作,但是我不確定如何將我的historyItemCollection(圖1)中的數據獲取到Observable集合(圖2)中?

圖。1:

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

圖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},
};

在historyitemcollection中,我有一個要放入軸值的日期項以及一個要放入值值的成本項(圖2 :)

如何將數據放入observableCollection中,以便可以使用此圖表控件?

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

或者在運行時

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