Just do the following for Casting dataGrid to data Table for in WPF:
DataTable dt = ((DataView)dataGrid1.ItemsSource).ToTable();or
dataTable = dataGridRecords.ItemsSource;
you can do in windowForm DataTable dataTable = new DataTable();
dataTable = dataGridRecords.DataSource;