开发者

How to get DataGrid row data after user has finished editing row?

I want to validate what the user has entered immediately after the user has finished entering a row in a d开发者_开发技巧atagrid.

What event should I be looking at, and how do I retrieve the row data? Or even better, the object it's bound to?


Use the RowEditEnding event.

private void DataGrid_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e)
{
  YourObject obj = e.Row.Item as YourObject;
  if (obj != null)
  {
     //see obj properties
  }
}


  1. Event RowEditEnding
  2. Data should be in e.Row.DataContext/e.Row.Item


If you're having problems, I had success using:

DataGridCellInfo selected = YourDataGrid.SelectedCells[0];
YourObject selectedRow = selected.Item as YourObject; 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜