title: Null reference exception with INotifyPropertyChanged when WPF DataGrid selection is not visible?
body: <p>I have a <code>DataGrid</code> control in which the user can select multiple items. After selecting the items and pressing a button, I iterate over each and edit a property. When this property is changed, the <code>INotifyPropertyChanged</code> events fire. It all works beautifully. However I have noticed that <strong>if I select two or more items</strong> and scroll such that one of the items is well out of view and <em>then</em> press the button the program will crash and give me a null reference exception in the <code>NotifyPropertyChanged()</code> method telling me that the <code>PropertyChangedEventHandler</code> is null. The code works normally if I remove the <code>NotifyPropertyChanged()</code> call from the property's setter, so for now that's what I'm doing, but why would this happen? It works as expected regardless of scroll position if I only have one item selected.</p>
  
  <p>In my model class, which implements the <code>INotifyPropertyChanged</code> interface, I have these:</p>
  
  <pre><code>    public event PropertyChangedEventHandler PropertyChanged;
      // ...
      public bool IsScheduled
      {
          get { return isScheduled; }
          set { isScheduled = value; NotifyPropertyChanged(self.ToString()); }
      }
      // ...
      private void NotifyPropertyChanged(string propertyName)
      {
          if (PropertyChanged != null)
              PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
      }
  </code></pre>
  
  <p>Elsewhere in the ViewModel I make this simple call which triggers the error:</p>
  
  <pre><code>process.IsScheduled = true;
  </code></pre>
  
  <p>If I check the values of the selected values list when the error occurs, all of the selected items <em>are</em> detected. it seems something happens with the event when they are invisible.</p>
  
  <p>Why does the visibility of the item in the view affect whether the event handler is null?</p>