In my WPF app I have a XamDataGrid. The grid is bound to an ObservableCollection. I need to allow users to insert new rows through the grid but it turns out that in order for the “Add New Row” row to be available, the xamDataGrid’s source needs to implement IBindingList. ObservableCollection does not implement that interface.
If I change my source to a BindingList, it works ok. However, from what I can understand from reading up on this topic, BindingList is really a WinForms thing and is not fully supported in WPF.
Would I be making a mistake if I changed all of my ObservableCollections to BindingLists? Does anyone have any other suggestions as to how I can get add new row functionality for my xamDataGrid while keeping the source as an ObservableCollection? It is my understanding that there are a number of different grids that require IBindingList to be implemented in order to support add new row functionality but most solutions I see are to just switch to BindingList.
Thanks.
The IBindingList interface and BindingList class are defined in the System.ComponentModel namespace, and so are not strictly Windows Forms related.
Have you checked if xamGrid supports binding to a ICollectionView source? If so, you could expose your data sources using this interface and back it using a BindingListCollectionView.
You could also create a subclass of
ObservableCollection<T>and implement the IBindingList interface:Alternately, you could subclass
BindingList<T>and implement the INotifyCollectionChanged interface.