c# - Loading a DataView into a DataGrid causes ShowDialog to hang? -
i have straightforward code:
var xldata = excel8oledbhelper.importexcelfile(filename); var viewmodel = new myviewmodel(xldata); _window = new mywindow(viewmodel); _window.showdialog();
the excel8oledbhelper.importexcelfile()
method works, can view datatable's content when debugging. problem _window
not show , thread behaves if did (i.e. it's waiting unshown window closed).
if change code this:
var viewmodel = new myviewmodel(new datatable()); _window = new mywindow(viewmodel); _window.showdialog();
then window appears, of course empty grid.
the xaml grid:
<datagrid x:name="mygrid" margin="4" isreadonly="true" selectionunit="cell" itemssource="{binding path=gridsource}" />
and viewmodel's constructor:
public dataview gridsource { get; private set; } public myviewmodel(datatable datasource) { gridsource = datasource.defaultview; }
this first time using wpf data grid maybe i'm doing wrong here, don't see how wrong grid prevent window showing @ all, without giving me exception , freezing app.
any clues? i'll gladly supply more code if missing!
update loading excel workbook 116 rows x 47 columns works; file need load has 5,000+ rows x 47 columns - wpf datagrid requires paging larger datasets? winforms datagridview had no issues , faster, assumed wpf counterpart work in similar fashion. problem showdialog
waiting data grid load data. assumed hung because didn't expect wpf datagrid take on minute winforms datagridview did instantly.
now have identified issue volume of data:
- do have row , column virtualization turned on ? can set enablerowvirtualization=true on datagrid
- are using auto-sized columns ? recomputing optimal size every new row/column can perf drag - try using fixed column size or proportional (1*) size. can try similar approach height rows.
Comments
Post a Comment