I cannot figure out why this is happening. Binding the DataGrid to a DataTable.DefaultView is causing the application to hang. I want to display the contents of a CSV file that has been parsed and placed in a DataTable. This approach using the backgroundWorker succeeds in WinForms, and this WPF app is a simple port of a small import utility to learn WPF. Here is the XAML
<DataGrid x:Name="detailGrid" AutoGenerateColumns="True" />
and here's the code behind:
private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
if (e.Error != null)
{
}
else if (e.Cancelled)
{
}
else
{
DataTable T = (e.Result as DataTable);
// verified in immediate window that T.Rows.Count = 80106 at this point
this.detailGrid.ItemsSource = T.DefaultView;
}
It's my understanding that the RunWorkerCompleted event is raised on the UI thread, so there's no need to do Dispatcher.Invoke( new Action() ... here.