wpf - How bind IList with many items to Datagrid without freezing -
hi parse txt file list , want bind collection wpf datagrid control.
txt file contain 18 000 - 19 000 rows. here sample of txt file.
910839320 hovory vo vps 24.05.2011 08:52 0910839253 vps stÁla 00:01:03 0,0488 910839320 hovory vo vps 26.05.2011 10:01 0910839267 vps stÁla 00:01:00 0,0465 910839320 hovory vo vps 26.05.2011 10:04 0910839263 vps stÁla 00:00:19 0,0147
i parse text file ilist function.
public class call { public string number { get; set; } public string calltype { get; set; } public string dt { get; set; } public string callingnumber { get; set; } public string voicenetwork { get; set; } public string type { get; set; } public string talktime { get; set; } public string price { get; set; } } private static ienumerable<call> parse(string path) { var calls = new list<call>(); string[] lines = system.io.file.readalllines(path); (int = 0; < lines.length; i++) { string[] line = lines[i].split('\t'); var call = new call { number = line[0], calltype = line[1], dt = line[2], callingnumber = line[3], voicenetwork = line[4], type = line[6], talktime = line[7], price = line[10] }; calls.add(call); } return calls; }
parsing ok.
problem if try bind output of mehod parse datagrid control. wpf freeze.
i use wpf, .net 4 , caliburn micro mvvm framework.
here problem code:
xaml:
<stackpanel orientation="vertical" grid.column="1"> <datagrid name="calls"/> </stackpanel>
viewmodel:
public ilist<call> calls { { return _class; } set { _class = value; notifyofpropertychange(()=>calls); } } public void opentsv() { task.factory.startnew(() => { var dlg = new microsoft.win32.openfiledialog { defaultext = ".tsv", filter = "tsv documents (.tsv)|*.tsv" }; bool? result = dlg.showdialog(); ilist<call> calls = new list<call>(); if (result == true) { path = dlg.filename; calls = tsvparser.parse(path); } execute.onuithread((system.action)(() => { calls = calls; })); }); }
how bind property calls viewmodel datagrid control without freezing?
a possible answer not load 18000 items. no person through items before filtering down more manageable number anyway.
Comments
Post a Comment