private void ButtonForRemoveRow_Click(object sender, RoutedEventArgs e) { OperationInModifingTable(); DataView dataView; if (Controller.GetController().DGContent == DataGridContent.ContentGrid) { dataView = DataGridForContent.ItemsSource as DataView; for (int i = dataView.Count - 1; i >= 0; i--) { var row = DataGridForContent.GetRow(i); if (row.IsSelected) { dataView.Delete(i); } } } else { dataView = DataGridForSchema.ItemsSource as DataView; for (int i = dataView.Count - 1; i >= 0; i--) { var row = DataGridForSchema.GetRow(i); if (row.IsSelected) { dataView.Delete(i); } } } }
private void ButtonForAddRow_Click(object sender, RoutedEventArgs e) { OperationInModifingTable(); if (Controller.GetController().DGContent == DataGridContent.ContentGrid) { DataView dataView = DataGridForContent.ItemsSource as DataView; dataView.AddNew(); for (int i = 0; i < dataView.Count - 1; i++) { var row = DataGridForContent.GetRow(i); row.IsEnabled = false; row.IsSelected = false; } var newRow = DataGridForContent.GetRow(dataView.Count - 1); newRow.IsSelected = true; } else { DataView dataView = DataGridForSchema.ItemsSource as DataView; dataView.AddNew(); for (int i = 0; i < dataView.Count - 1; i++) { DataGridRow row = DataGridForSchema.GetRow(i); row.IsEnabled = false; row.IsSelected = false; } DataGridRow newRow = DataGridForSchema.GetRow(dataView.Count - 1); newRow.IsSelected = true; } }