我有ListView
我想填充。 我想要做的就是讓我的List
與所有項目,並將此添加到我的ListView
,但我希望它是逐漸。將文件逐個添加到我的ListView中
我List
Dictionary<string, double> collection;
型號:
public class MainViewModel
{
public DataTable PieData { get; private set; }
public MainViewModel()
{
this.PieData = GetTestData();
}
private static DataTable GetTestData()
{
DataTable dtData = new DataTable("DATA");
dtData.Columns.Add(new DataColumn("Name", typeof(string)));
dtData.Columns.Add(new DataColumn("Value", typeof(double)));
foreach (KeyValuePair<string, double> item in collection)
dtData.Rows.Add(new object[] { item.Key, item.Value });
return dtData;
}
}
我的計時器:
private DispatcherTimer timer;
public void CreateTimer()
{
timer = new DispatcherTimer();
timer.Tick += timer_Tick;
timer.Interval = new TimeSpan(0, 0, 0, 0, 100);
}
添加到我的ListView
通過我的計時器:
private void timer_Tick(object sender, EventArgs e)
{
foreach (KeyValuePair<string, double> item in collection)
ipStatisticsListView.Items.Add(new MyItem { IP = item.Key, Percent = item.Value });
}
目前是什麼情況是,雖然我每間申報100毫秒添加操作我有延遲半秒,比我能看到裏面我所有的名單我LisView
據我所知,這將* all *項目每100毫秒添加到列表視圖。 –