My question is somewhat related to:
Wpf datagrid scrollbar freezes
After adding a data table to a data grid:
<DataGrid Name="appliedJobs" Background="#50000000" Grid.Row="1" Grid.Column="1" Margin="10,10,10,10" ItemsSource="{Binding dataTable.DefaultView}" AutoGenerateColumns="True" />
private void GenerateTableButton_Click(object sender, RoutedEventArgs e)
{
string table = readStuffFromFile();
// Parse stuff read from file into a table
DataTable dataTable = InitializeTable(table);
// Set binding
appliedJobs.ItemsSource = dataTable.AsDataView();
}
Scrolling sideways is fine, but whenever I get to the bottom of the table the app freezes (100% CPU use (per thread)). Why?
The table structure is not fixed. It can be anything:
id | date
---------------------
1 | 13.05.2020
2 | 10.05.2020
3 | 18.05.2020
or
id | position | requirements
------------------------------------
1 | dev | 5 years exp
2 | tech lead | 8 years exp
3 | dev | 4 years exp
The DataTable should thus be dynamically created. Most samples found on SO use a fixed class for headers and values.