If my itemsource already has a very large datatable source for example with 6000+ columns and one line then update it to a small table by changing the itemsource.
private static void OnItemsSourcePropertyValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var dynamicGrid = d as DynamicGrid;
if (dynamicGrid == null)
return;
try
{
dynamicGrid.ItemsSource.Dispose();
dynamicGrid._grid.SelectedItems.Clear();
dynamicGrid._grid.SelectedItem = null;
dynamicGrid._grid.Rebind();
dynamicGrid.ItemsSource = null; stop here and no exception,code stop running
dynamicGrid.ItemsSource = e.NewValue as DataTable;
}
}