1

I've been trying to find out how to be notified (i.e. have a handler) when user edits or adds a new row in the DataGrid. As for editing, the closest I could find is RowEditEnding handler, but the problem with that handler is that I can't access the new values of the cells in the row being edited. This handler has only the old values, cause the event is triggered right before the data is committed.

Anyways, the list that is bound to the DataGrid is being properly updated both on edit and add, but what I want is to do appropriate SQL queries and update the sql table cause the list is made out of data pulled from the Database.

Any ideas?

  • Your question is very similar to: http://stackoverflow.com/questions/4617810/wpf-datagrid-event-for-new-rows – Johan Larsson Sep 30 '12 at 17:29
  • I can bind it to a DataTable as suggested in http://stackoverflow.com/questions/4617810/wpf-datagrid-event-for-new-rows and then listen to appropriate events. However, I want to bind it to a List (or ObservableCollection) and there is no appropriate event for editing rows. – Огњен Шобајић Sep 30 '12 at 18:01
  • So any thoughts in the case with biding to a list? – Огњен Шобајић Sep 30 '12 at 18:10
  • I still feel this logic should not be handled in the view. Do the objects in the List implement INotifyPropertyChanged? – Johan Larsson Sep 30 '12 at 18:13
  • No. They are simple container objects. Why do they need to implement this interface? Can you please explain? Thanks – Огњен Шобајић Sep 30 '12 at 18:26
  • Then you could listen for PropertyChanged for the items: http://stackoverflow.com/questions/1015126/observable-collection-property-changed-on-item-in-the-collection But doing this from the view does not feel right. i feel that the view should not handle the db being updated. – Johan Larsson Sep 30 '12 at 18:31
  • Are you using some sort of wpf spy tool? That can be helpful to find events and such. http://stackoverflow.com/questions/1672696/is-there-a-spy-like-utility-for-wpf – Johan Larsson Oct 01 '12 at 06:48

0 Answers0