LinqObservableCollection / AllowEdit, AllowNew, AllowDelete

LinqObservableCollection / AllowEdit, AllowNew, AllowDelete

Old forum URL:

Stephen K posted on Friday, May 06, 2011


I was wondering if LingObservableCollaction supports the concept of AllowNew, AllowDelete? 

I have a datagrid that I have bound to the following property and have set the bindings for CanUserAddRow and CanUserDeleteRows.  The underlying collection was set to AllowNew=False and AllowDelete = False.  The datagrid does not work as expected.  I originally had the property return the original collection and everything worked as expected.

















Public Shared _criteriaValues As BoPropertyInfo(Of CriteriaValueCollection

) = _




Of CriteriaValueCollection)(New BoPropertyInfo(Of CriteriaValueCollection

) _




"CriteriaValues", RelationshipTypes.Child, Nothing








Public ReadOnly Property CriteriaValues() As LinqObservableCollection(Of CriteriaValue









Return (From r In ReadProperty(_criteriaValues) Order By r.Key Select












RockfordLhotka replied on Friday, May 06, 2011

No, the ObservableCollection type doesn't support those concepts. Those were part of the BindingList<T> (IBindingList) type collections for Windows Forms.

ObservableCollection got rid of almost all those concepts. As a result, an ObservableCollection generally won't work correctly in Windows Forms.

In WPF, conversely, only ObservableCollection works right, and BindingList works partially. Except that some third-party WPF datagrid controls work with BindingList (and don't necessarily work with ObservableCollection).

This makes WPF development a mess, at least if you are using datagrid controls.

If you are doing Windows Forms you should avoid LinqObservableCollection, and use SortedBindingList/FilteredBindingList to do your sorting and filtering. You should also be using the correct collection base types (BusinessBindingListBase instead of BusinessListBase, etc).

Copyright (c) Marimer LLC