DataGrid使用右键选中当前行
今天有朋友问到DataGrid控件右键选中当前行的问题,对该方法做一个记录。
void dg_LoadingRow(object sender, DataGridRowEventArgs e) { e.Row.MouseRightButtonDown += (s, a) => { a.Handled = true; (sender as DataGrid).SelectedIndex = (s as DataGridRow).GetIndex(); (s as DataGridRow).Focus(); }; }