我从 WPF 扩展工具包中填充 aa DataGridControl
,并在用户选择时填充 DataTables。当用户选择被修改时,不仅显示具有 200 x 1000 行的 DataTable 会有很大的延迟,而且还会存在阻止用户与其他控件交互的用户交互延迟,即使绑定到的 DataTable 的填充DataGridControl
发生在一个单独的线程。
如何消除延迟,以便用户可以在 DataGridControl 更新时与视图中的其他控件进行交互?
public string ListBoxSelection {
get {
return listBoxSelection;
}
set {
listBoxSelection = value;
OnPropertyChanged("ListBoxSelection"); // DataGridSelection
BackgroundWorker threadPreviewLoader = new BackgroundWorker();
threadPreviewLoader.DoWork += (LoadDataGridPreview);
threadPreviewLoader.RunWorkerAsync();
}
}
private DataTable dTPreviewWindow; //modified in thread
public DataView dvLbSelection {
get {
return dTPreviewWindow.DefaultView; //DataGridControl binding
}
}
private void LoadDataGridPreview(object sender, DoWorkEventArgs e) {
if (listBoxSelection != null) {
try {
DataTable testImmediateChange = new DataTable();
testImmediateChange = DataSetModel.ChunkFlatFile(listBoxSelection, 1, PREVIEW_WINDOW_MAX_ROWS); //labor itensive work
dTPreviewWindow = testImmediateChange;
fileOpenGood = true;
} catch {
fileOpenText = DATAGRID_TEXT_BADFILE;
fileOpenGood = false;
}
fileOpenText = DATAGRID_TEXT_NOFILECHOSEN;
OnPropertyChanged("FileOpenGood");
OnPropertyChanged("FileOpenBad");
OnPropertyChanged("FileOpenText");
OnPropertyChanged("dvLbSelection");
} else {
ValidatePreviewWindow(true);
}
}