I am using .NET 4 with WPF and the Entity Framwork. I want to have editable rows in a DataGrid representing EF Entities that are saved automatically to the database when the user jumps to another row (standard behavior, like the old Access tables ;-).
The RowEditEnding event handler of the Datagrid is nicely called when the focus leaves the row - exactly what I want. But inside the RowEditEnding handler the new values in the row are not yet assigned to the underlying Entity so calling EF's dataContext.SaveChanges()
is useless at this point. Have I missed another event handler which is called after the values have been transfered to my business object? Or is there another good solution for calling SaveChanges() after the user has left a row?
Thanks for your hints.
Please note: I know about DataGrid's awareness of the IEditableObject, but would would like to avoid it. EF's entity classes inherit from EntityObject which does not implement IEditableObject. As Entities already inherit from some class I can not inherit
from a generic IEditableObject implementation and would have to manually add that to all my entity classes. Also: except for "bad timing" mentinoned above the DataGrid already does 95% of what I want.
View Complete Post