Hi,
I have binded a list with Editable WPF DataGrid
I want to get only the modified Items from the WPF Data Grid for updation.
Please let me know how to do this.
Hi,
I have binded a list with Editable WPF DataGrid
I want to get only the modified Items from the WPF Data Grid for updation.
Please let me know how to do this.
Well there is a RowState property on your data row (there is also a RowChanged event), but make sure you need this. Am I under the wrong assumption that databinding automatically figures out which rows need to be updated?
I have my WPF datagrid app set up as so:
1) Manually defined all the columns, set their bindings and for each binding specified that it notifies on source updates
2) Added an event handler for the datagrid's SourceUpdated event
3) In the event handler I have only the following code:
this.updatedItems.Add(BindingOperations.GetBindingExpression(e.TargetObject, e.Property).DataItem as MyClass);
updatedItems is a HashSet<> and MyClass is the type of objects bound to the datagrid's ItemsSouce.
4) When the user clicks on the save button I simply enumerate the hashset. Hashset is nice, because it only contains unique values. So if a row is edited multiple times or even if multiple cells in the same row are edited, the hashset will still only contain a single entry for the object.