开发者

How to implement IEditableCollectionView interface

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.

开发者_JS百科

Thanks.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜