title: Best way to notify property change when field is depending on another
body: <p>What is the best way in c# to notify property changed on an item's field without <code>set</code> but <code>get</code> depends on other fields ?</p>
  
  <p>For example :</p>
  
  <pre><code>public class Example : INotifyPropertyChanged
  {
      private MyClass _item;
      public event PropertyChangedEventHandler PropertyChanged;
  
      public MyClass Item
      {
          get
          {
              return _item;
          }
          protected set
          {
              _item = value;
              OnPropertyChanged("Item");
          }
      }
  
      public object Field
      {
          get
          {
              return _item.Field;
          }
      }
  #if !C#6
      protected void OnPropertyChanged(string propertyName)
      {
          PropertyChangedEventHandler handler = PropertyChanged;
  
          if (handler != null)
          {
              handler(this, new PropertyChangedEventArgs(propertyName));
          }
      }
  #else
      protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
      {
          PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
          // =&gt; can be called in a set like this: 
          // public MyClass Item { set { _item = value; OnPropertyChanged();} }
          // OnPropertyChanged will be raised for "Item"
      }
  #endif
  }
  </code></pre>
  
  <p>What the best way to rise a PropertyChanged for <code>"Field"</code> when setting <code>Item</code> ? I wanted to call<code>OnPropertyChanged("Field");</code> when setting <code>Item</code> but if I had many fields the code will quickly be ugly and unmaintainable.</p>
  
  <p>Edit:</p>
  
  <p>I wonder if there is a function/method/attribute working like this :</p>
  
  <pre><code>[DependOn(Item)]
  public object Field
  {
      get
      {
          return _item.Field;
      }
  }
  </code></pre>
  
  <p>=> When <code>Item</code> changes, all the depending fields will notify the property changed.</p>
  
  <p>Does it exist ?</p>