WPF DataGrid选中改变时,还原选中行
程序员文章站
2022-03-07 17:06:12
...
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;
上一篇: WPF动画