I have a datagrid. I want to add columns as a result of an event. So I do
for (int iii = 1; iii <= 4; ++iii)
{
var dtgColumn = new DataGridTextColumn();
dtgColumn.Header = "AAA"
Dispatcher.Invoke((Action)(() => { dtgResults.Columns.Add(dtgColumn); }));
}
But despite using a dispatcher I get this error:
The calling thread cannot access this object because a different thread owns it.
Thank you for any help Patrick }