问题
I have a DataGrid and a DataForm. I'm assigning data to the DataForm with the currently selected Item in the datagrid individually as DataForm.CurrentItem
. This means that I do not have any Next/Previous button on the DataForm and the user can switch to any row in the DataGrid.
My problem is that although I have set the property AutoCommit="True"
on the DataForm, if the user edits something and clicks on another record in the DataGrid, it crashes.
How can I force it to save the DataForm when the user moves away from the form?
回答1:
I got this working but I'm not sure whether this is correct. On SelectionChanged event of datagrid I added the following:
DataForm.CommitEdit();
and it stopped crashing and giving me the error. If anyone else has a better solution please do let me know.
来源:https://stackoverflow.com/questions/3969588/silverlight-4-dataform-currentitem-and-autocommit