Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom collection crashes DataGrid on Edit

Im currently trying to bind the DataGrid.ItemsSource to a custom RowCollection, which implements IList and INotifyCollectionChanged:

Public Class RowCollection(of T)
Implements IList(Of T)
Implements INotifyCollectionChanged
Private _List As New List(Of T)
...

(Sorry for the VB code, I'll be translating all my code to C# soon.)

Notice the class does not derive from any existing CLR collection. I created my own class because I need to override GetItemAt, in order to implement record paging. The Collection Internally adds and removes objects from its own private List _List.

Now, I am able to view the items in a DataGrid, but as soon as I double click a cell to edit, I recieve an InvalidOperationException: 'EditItems' is not available..

My question is, what other interfaces should I implement in order to make my collection fully compatible with DataGrid?

like image 784
Federico Berasategui Avatar asked Mar 03 '11 13:03

Federico Berasategui


1 Answers

Here you can read the following:

Editing

By default, you can edit items directly in the DataGrid. To guarantee that edits can be committed and canceled correctly, the objects in the DataGrid must implement the IEditableObject interface. Alternatively, you can set the IsReadOnly property to true to disable editing in the DataGrid.

The IEditableObject interface is here Also see IEditableCollectionView here

like image 98
Vincent Vancalbergh Avatar answered Sep 29 '22 14:09

Vincent Vancalbergh