I need to persist the value of a cell when the user leaves it. This sounds like a quite normal use case but apparently this isn't very Google’able.
I have a working solution using the DataGrid_CellEditEnding and delaying the persisting logic on the Dispatcher since the model hasn’t been updated yet.
There must be other ways to do this!?
privatevoid DataGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
{
Action action = () =>
{
var row = e.Row.ItemasMyRow;
row.RootModel.Save(row);
};
//TODO : WTF! :)
//we need to execute this on the gui queue, since the viewmodel has not been updated yet!
//http://stackoverflow.com/questions/2094615/textchanged-lostfocus-etc-event-for-datagridtextcolumn
Dispatcher.BeginInvoke(action,DispatcherPriority.ContextIdle);
}