title: Subscribe to INotifyPropertyChanged for nested (child) objects
body: <p>I'm looking for a clean and <strong>elegant</strong> solution to handle the <code>INotifyPropertyChanged</code> event of nested (child) objects. Example code:  </p>
  
  <pre><code>public class Person : INotifyPropertyChanged {
  
    private string _firstName;
    private int _age;
    private Person _bestFriend;
  
    public string FirstName {
      get { return _firstName; }
      set {
        // Short implementation for simplicity reasons
        _firstName = value;
        RaisePropertyChanged("FirstName");
      }
    }
  
    public int Age {
      get { return _age; }
      set {
        // Short implementation for simplicity reasons
        _age = value;
        RaisePropertyChanged("Age");
      }
    }
  
    public Person BestFriend {
      get { return _bestFriend; }
      set {
        // - Unsubscribe from _bestFriend's INotifyPropertyChanged Event
        //   if not null
  
        _bestFriend = value;
        RaisePropertyChanged("BestFriend");
  
        // - Subscribe to _bestFriend's INotifyPropertyChanged Event if not null
        // - When _bestFriend's INotifyPropertyChanged Event is fired, i'd like
        //   to have the RaisePropertyChanged("BestFriend") method invoked
        // - Also, I guess some kind of *weak* event handler is required
        //   if a Person instance i beeing destroyed
      }
    }
  
    // **INotifyPropertyChanged implementation**
    // Implementation of RaisePropertyChanged method
  
  }
  </code></pre>
  
  <p>Focus on the <code>BestFriend</code> Property and it's value setter. Now <strong>I know that I could do this manually</strong>, implementing all steps described in the comments. But this is going to be a lot of code, especially when I'm planning to have many child properties implementing <code>INotifyPropertyChanged</code> like this. Of course they are not going to be always of same Type, the only thing they have in common is the <code>INotifyPropertyChanged</code> interface.</p>
  
  <p>The reason is, that in my real scenario, I have a complex "Item" (in cart) object which has nested object properties over several layers (Item is having a "License" object, which can itself have child objects again) and I need to get notified about any single change of the "Item" to be able to recalculate the price.</p>
  
  <p><strong>Do you some good tips or even some
  implementation to help me to solve
  this?</strong></p>
  
  <p>Unfortunately, I'm not able/allowed to use post-build steps like PostSharp to accomplish my goal.</p>