An exception of type 'System.InvalidOperationException' occurred in System.Windows.Data but was not handled in user code Additional information: 'Refresh' is not allowed during an AddNew or EditItem transaction.1) Add a GotFocus="Button_GotFocus" to the event with method:
private void Button_GotFocus(object sender, RoutedEventArgs e) { dataGrid1.CommitEdit(DataGridEditingUnit.Row, true); }Evidently, GotFocus fires before Click here, so it is the place to exit Edit mode.
2) Wrap the pagedCollectionView.Refresh() call in an asynchronous call:
Deployment.Current.Dispatcher.BeginInvoke( () => { pagedCollectionView.Refresh(); });Evidently, the asynch call delays the refresh long enough so that the row can exit edit mode. These are workarounds that signal a compromise with MVVM and elegance in general, but until I find a better solution, it is what it is.
No comments:
Post a Comment