I have a WPF User Control with a datagrid sitting within a WinForms form. The datagrid is bound to a datasource using the ItemsSource binding. It all works fine so when data is changed the changes propogate to the object model.
However, if the user is editing data in the datagrid and then clicks on the Close button of the hosting container then the datagrid doesn't update the binding, presumably because it doesn't think it's lost focus. The form closes and the changes are lost.
The same problem is also true for text boxes but I can get around that by using the UpdateSourceTrigger=PropertyChanged so that the underlying model is constantly being updated as the text changes. Not ideal - but it avoids the problem.
Does anyone know how to either switch the datagrid into PropertyChanged mode for updating the source, or do something to force the datagrid to save the changes through the binding to the underlying object?
While researching this I found this article helpful: http://www.jerryhuang.net/post/Force-a-data-binding-to-update.aspx
Thanks