if (index != dataGrid1.SelectedIndex && System.Windows.Forms.MessageBox.Show("1", "", System.Windows.Forms.MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.Cancel)
{
Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Loaded, new Action(() =>
{
dataGrid1.SelectionChanged -= dataGrid1_SelectionChanged;
dataGrid1.SelectedIndex = index;
dataGrid1.SelectedItem = dataGrid1.Items[index];
dataGrid1.CurrentItem = dataGrid1.Items[index];
dataGrid1.SelectionChanged += dataGrid1_SelectionChanged;
}));
return;
}
index = dataGrid1.SelectedIndex;