title: What's the order of execution in property setters when using IDataErrorInfo?
body: <p><strong>Situation:</strong> Many times with WPF, we use <code>INotifyPropertyChanged</code> and <code>IDataErrorInfo</code> to enable binding and validation on our data objects. I've got a lot of properties that look like this:</p>
  
  <pre><code>public SomeObject SomeData
  {
      get { return _SomeData; }
      set { _SomeData = value; OnPropertyChanged("SomeData"); }
  }
  </code></pre>
  
  <p>Of course, I have an appropriate overridden <code>IDataErrorInfo.this[]</code> in my class to do validation.</p>
  
  <p><strong>Question:</strong> In a binding situation, when does the validation code get executed? When is the property set? When is the setter code executed? What if the validation fails?</p>
  
  <p>For example:</p>
  
  <ol>
  <li>User enters new data.</li>
  <li>Binding writes data to property.</li>
  <li>Property <code>set</code> method is executed.</li>
  <li>Binding checks <code>this[]</code> for validation.</li>
  <li>If the data is invalid, the binding sets the property back to the old value.</li>
  <li>Property <code>set</code> method is executed again.</li>
  </ol>
  
  <p>This is important if you are adding "hooks" into the set method, like:</p>
  
  <pre><code>public string PathToFile
  {
      get { return _PathToFile; }
      set
      {
          if (_PathToFile != value &amp;&amp;      // prevent unnecessary actions
              OnPathToFileChanging(value)) // allow subclasses to do something or stop the setter
          {
              _PathToFile = value;
              OnPathToFileChanged();  // allow subclasses to do something afterwards
              OnPropertyChanged("PathToFile");
          }
      }
  }
  </code></pre>