Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1150
Binding with synchronized CurrentItem raises Exception on canceling AddNew
posted

Hello,

to a XamDataGrid I bind a collection of simple objects.
The collection is based on  ObservableCollection<T> and additional implements IBindingList
so it supports CurrentItem, object addings and removings.

I need the features of the ObservableCollection.
The IBindingList I've only implemented, because without it the grid was not able to do AddNew rows at all. 

This works well until I add the IsSynchronizedWithCurrentItem="True" option to the grid.
As soon I add a new record but cancel it with Escape, an exception is thrown by the collection:
Remove is not allowed while an AddNew or EditItem transaction (free translated from german).

I managed to circumvent this issue by catching the grids RecordUpdateCanceling
and call the CommitNew() method of the collections IEditableCollectionView within the event handler.
But I think of this as an ugly hack. Not only that calling CancelNew() isn't enough, I think it should be not needed at all to work proper.

To make life easier I added an working (exception throwing) sample.
You find further issue related comments within MainWindow.xaml.cs

A great thank you in advance! 

XamDataGridAddNewCancel.zip
Parents
No Data
Reply
  • 35319
    posted

    Hello,

     

    I have logged this behavior with our developers in our tracking system, with an issue ID of 178220.  I have also created a support ticket on your behalf with number CAS-142269-Q0Y2G4 in order to link the development issue to it so that you are automatically updated when a Service Release containing your fix is available for download.

Children