I have this exception when using my application. I know more or less where it comes from :
My application uses tabs. I open a tab containing a datagrid. When i double click on a cell, it automatically creates a new object (in the collection binded). However, lets say my cell is still in editing mode. If i open a new tab, and then want to go back in the previous one, I get this error message.
To avoid this problem, I would like my cell to stop editing mode anytime i click somewhere else.
Thanks by advance for your help.
What is the error message, could you share it? Is it "'DeferRefresh' is not allowed during an AddNew or EditItem transaction"? And it seems a issue of WPF Toolkit DataGrid, Please refer to this link: http://wpf.codeplex.com/WorkItem/View.aspx?WorkItemId=7830 So could you please try to use the latest version of WPF Toolkit or try to code it in the Visua lStudio 2010 with .Net 4(WPF 4 has a DataGrid control)
However, it is hard to find the cause without any code, could you please share some code about your application?
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
For your information, I fully documented a similar case in
When you click on " Bug 551128 : Details/Expand", you can download a documented zip file with all material I could produce for the defer Refresh exception.
If this case matches yours, you can add a vote for 551128 and 532494 (top left)
If your scenario is (even slightly) different, feel free to add your own zip file to 551128 or to open your own DeferRefresh bug entry. This can always help the development/maintenance teams.
Kind regards, Chris.
Hi, I built a workaround for this, which is documented in thread
It basically gets the datagrid out of edit mode (canceling the pending changes) when it loses focus or changes its DataContext. I don't report the whole solution also in this thread, because it is a bit long, so please visit that link.
documents the limit of the proposed workaround : the model class must implement 'IEditableObject'
- Edited by Rhodos Saturday, October 09, 2010 8:59 AM updating answer completeness
If at all possible, you could upload a file attachment with your (simplified) Solution/Project in
https://connect.microsoft.com/VisualStudio/feedback/details/532494/wpf-datagrid-and-tabcontrol-deferrefresh-exception#details (or open an additional connect report)
Your case is quite interesting since you are declaring IEditableObject on your class, a feature that precisely should help avoiding the problem, not cause it.
Basically I have a tab control in the GUI and there is WPF 4.0 datagrid in one of the tabs. When I click on a cell in the grid and edit something and then switch tabs I was getting Defer Refresh error (DeferRefresh' is not allowed during an AddNew or EditItem transaction.).
So I call datagrid.CancelEdit(DataGridEditingUnit.Row) when tab is switched to cancel any pending edit and Defer refresh issue is gone.
But what I really want to do is CommitEdit() so that the user doesn't have to reenter the data again. And datagrid.CommitEdit(DataGridEditingUnit.Row, true) doesn't work for me.
I get the below error on CommitEnd(): "Cannot perform this operation while dispatcher processing is suspended".
Any help is appreciated.
PS: I have tried datagrid.CommitEdit() and datagrid.CommitEdit(DataGridEditingUnit.Column, true) and it didnt work.
- Edited by Nikhil Kesar Friday, August 16, 2013 8:32 PM typo