Error when cleaning a DataGrid

0

After I've saved my items that are in the DataGrid to a database, I'd like it cleaned up. So I used it like this:

dg.Items.Clear();

But then this error appears:

  

Operation is not valid while ItemsSource is in use. Access and modify elements with ItemsControl.ItemsSource instead.

Is it being used or something? How do I fix this?

    
asked by anonymous 10.06.2015 / 20:03

1 answer

1

Have you tried doing this here:

dg.ItemsSource = null;
dg.Items.Refresh();
    
10.06.2015 / 20:12