-
Notifications
You must be signed in to change notification settings - Fork 0
IObservableReadOnlyList
Make read-only lists observable.
Now, you might think: Why should I make a list with read-only access observable? Why should I wait for it to change? The short answer is that these lists are proxies to other obsevable lists. These other lists can be observable read-only lists, too, or ObservableCollections. What purpose the concrete implementations of this interface have, you can look up on their wiki pages.
The interface is a composition of the IReadOnlyList, INotifyCollectionChanged and INotifyPropertyChanged interfaces. All of which are supported by WPF elements, so it has the same effect like an ObservableCollection on the WPF UI. Note that the typ T is marked as out, which allows it to be used in co-variant way:
IObservableReadOnlyList<DerivedClass> derivedItemsList = new WrappingObservableReadOnlyList<DerivedClass>(new ObservableCollection<DerivedClass>());
IObservableReadOnlyList<BaseClass> baseItemsList = derivedItemsList; //legit, because DerivedClass inherits from BaseClass and the interfaces type is co-variant
The co-variance feature is a requirement for the ConcatenatingObservableReadOnlyList (see it's wiki page).