Kalanamith
Kalanamith

Reputation: 20648

DataGrid CellEditending event does not return the updated value in the cell

I'm trying to get the currently edited and updated item from WPF Datagrid. This is my code:

private void onCellEdit (object sender, DataGridCellEditEndingEventArgs e)
{                
    VML.MyViewModel.CurrentPackage = (MyPackage )e.EditingElement.DataContext;                   
}

Binding Property

Mode=TwoWay, UpdateSourceTrigger=Default

Unfortunately this will return the value before editing the cell, the atttibutes are not updated, values available in the EditingElement.DataContext has older values before editing.

Is there a way I can get the edited value without using selectedrowchange event since it won't work with the last row?

Upvotes: 1

Views: 2002

Answers (1)

bars222
bars222

Reputation: 1660

For DataGridTextColumn you can get edited value by this.

( e.EditingElement as TextBox ).Text

Upvotes: 3

Related Questions