views:

56

answers:

1

Can anyone please tell me how to implement IEditableCollectionView interface? I am trying to use a custom list for data binding to a data grid in WPF (C#) and need to implement this interface for editing data.

Thanks.

A: 

I'm pretty sure the objects in the IEditableCollectionView have to implement IEditableObject interface for it to work well.

I use it as a wrapper for another collection.

 ObservableCollection<ObjectType> Collection = new ObservableCollection<ObjectType>( getObjectsFromDatabaseMethod() );
 ICollectionView CollectionView = CollectionViewSource.GetDefaultView(Collection); // View wich you can sort and filter with
 IEditableCollectionView EditableCollectionView = CollectionView as IEditableCollectionView; // Gives you the editview

EditableCollectionView.AddNew(); // adds a new item of type ObjectType
EditableCollectionView.EditItem( a_instance_from_collection);
EditableCollectionView.CommitEdit();
EditableCollectionView.CancelEdit();

I'm not sure this is the best way byt it is A way.

Ingó Vals