InvalidOperationException 'EditItem' is not allowed for this view

Nov 18, 2009 at 6:22 AM

I have a DataGrid.

My columns are DataGridTextColumn

When the ItemsSource is an ObservableCollection<T> it all works fine.

However when it is a
class MyCustomCollection<T> : IList<T>, INotifyCollection

It throws an exception when I double click on a cell to try to edit.
The error happens at:

at System.Windows.Controls.ItemCollection.System.ComponentModel.IEditableCollectionView.EditItem(Object item)
   at Microsoft.Windows.Controls.DataGrid.EditRowItem(Object rowItem) in D:\WorkAgtrix\Dev\WPFToolkitBinariesAndSource\Toolkit-release\DataGrid\Microsoft\Windows\Controls\DataGrid.cs:line 3396
   at Microsoft.Windows.Controls.DataGrid.OnExecutedBeginEdit(ExecutedRoutedEventArgs e) in D:\WorkAgtrix\Dev\WPFToolkitBinariesAndSource\Toolkit-release\DataGrid\Microsoft\Windows\Controls\DataGrid.cs:line 2208
   at Microsoft.Windows.Controls.DataGrid.OnExecutedBeginEdit(Object sender, ExecutedRoutedEventArgs e) in D:\WorkAgtrix\Dev\WPFToolkitBinariesAndSource\Toolkit-release\DataGrid\Microsoft\Windows\Controls\DataGrid.cs:line 2036
   at System.Windows.Input.CommandBinding.OnExecuted(Object sender, ExecutedRoutedEventArgs e)

 at System.Windows.Controls.ItemCollection.System.ComponentModel.IEditableCollectionView.EditItem(Object item)
 at Microsoft.Windows.Controls.DataGrid.EditRowItem(Object rowItem) in D:\WorkAgtrix\Dev\WPFToolkitBinariesAndSource\Toolkit-release\DataGrid\Microsoft\Windows\Controls\DataGrid.cs:line 3396
 at Microsoft.Windows.Controls.DataGrid.OnExecutedBeginEdit(ExecutedRoutedEventArgs e) in D:\WorkAgtrix\Dev\WPFToolkitBinariesAndSource\Toolkit-release\DataGrid\Microsoft\Windows\Controls\DataGrid.cs:line 2208
 at Microsoft.Windows.Controls.DataGrid.OnExecutedBeginEdit(Object sender, ExecutedRoutedEventArgs e) in D:\WorkAgtrix\Dev\WPFToolkitBinariesAndSource\Toolkit-release\DataGrid\Microsoft\Windows\Controls\DataGrid.cs:line 2036
 at System.Windows.Input.CommandBinding.OnExecuted(Object sender, ExecutedRoutedEventArgs e)

I gather that CollectionViewSource create the wrong type of default view... any idea on how to fix that?

 

Nov 18, 2009 at 11:22 PM

I fixed the problem no worries!

 

.

.

.

.

Ok, I tell ya how!
Just Implemented IList as well (you know, the non generic System.Collections.IList)