Search code examples
c#wpfwpf-controlswpfdatagrid

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 datagrid.

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


Solution

  • 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
      }
    }