Why is ReadOnlyObservableCollection.CollectionChanged not public?

后端 未结 8 2113
心在旅途
心在旅途 2021-01-31 06:50

Why is ReadOnlyObservableCollection.CollectionChanged protected and not public (as the corresponding ObservableCollection.CollectionChanged is)?

What is the use of a col

8条回答
  •  一整个雨季
    2021-01-31 07:19

    I've found a way for you of how to do this:

    ObservableCollection obsCollection = new ObservableCollection();
    INotifyCollectionChanged collection = new ReadOnlyObservableCollection(obsCollection);
    collection.CollectionChanged += new NotifyCollectionChangedEventHandler(collection_CollectionChanged);
    

    You just need to refer to your collection explicitly by INotifyCollectionChanged interface.

提交回复
热议问题