However, using this code one must be aware that if not unsubscribed, there might be a potential memory leak here. In Catel, there is a solution for such cases that can raise change notifications using weak events called the ChangeNotificationWrapper. It allows the subscription of both the INotifyPropertyChanged and INotifyCollectionChanged interfaces.

Subscribing to events of an observable object

Using the code below, one can subscribe to the PropertyChanged event of an object:

Subscribing to events of an observable collection

Note that it is not required to check whether the object implements INotifyCollectionChanged, the wrapper does it automatically

Advanced scenario with observable collections

Sometimes it is required to watch both changes inside a collection, but also the items inside a collection. For example, there is a list of customers and you are also interested in changes of customers inside a collection. This is fully supported by the ChangeNotificationWrapper using the code below: