title: Handling OnPropertyChanged
body: <p>I'm not well versed in event-based programming. Basically, I'm still stumbling around with it. I'm trying to get something set up, but even with the tutorials, I can't wrap my head around it. What I would like to do (in words) is the following:</p>
  
  <ol>
  <li><p>I have a dataobject where a property changes. I notice this in the setter of the property, and want to raise an event that the property has changed.</p></li>
  <li><p>Elsewhere (in a different class entirely), I want to know that the property on this object has changed, and take some action.</p></li>
  </ol>
  
  <p>Now I'm sure this is a common enough scenario, but my google-fu is letting me down. I'm simply not understanding <a href="http://msdn.microsoft.com/en-us/library/ms743695.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/ms743695.aspx</a>.</p>
  
  <p>I have this:</p>
  
  <pre><code>public class ChattyClass {
    private int someMember;
  
    public event PropertyChangedEventHandler PropertyChanged;
  
    public int SomeMember {
      get {
        return this.someMember;
      }
      set {
        if (this.someMember != value){
          someMember = value;
          // Raise event/fire handlers. But how?
        }
     }
  }
  
  public class NosyClass{
    private List&lt;ChattyClass&gt; myChatters;
  
    public void addChatter(ChattyClass chatter){
      myChatters.add(chatter);
      // Start listening to property changed events
    }
  
    private void listner(){
      // I want this to be called when the PropertyChangedEvent is called
      Console.WriteLine("Hey! Hey! Listen! A property of a chatter in my list has changed!");
    }
  }
  </code></pre>
  
  <p>What do I do to wire this up?</p>
  
  <p>Concerning the comment pointing me back to the link:</p>
  
  <p>In the example I see:</p>
  
  <pre><code>protected void OnPropertyChanged(string name)
  {
      PropertyChangedEventHandler handler = PropertyChanged;
      if (handler != null)
      {
          handler(this, new PropertyChangedEventArgs(name));
      }
  }
  </code></pre>
  
  <p>What I'm not understanding:</p>
  
  <ul>
  <li>Why isn't this just calling <code>PropertyChanged(this, new PropertyCHangedEventArgs(name))</code></li>
  <li>Where does PropertyChanged get assigned?</li>
  <li>What does the assignment look like?</li>
  </ul>