title: How to read current edited value during Row Validation Rule WPF datagrid
body: <p>I have this Validation Rule:</p>
  <pre><code> public override ValidationResult Validate(object value, CultureInfo cultureInfo) {
  
          DteqModel Dteq = (value as BindingGroup).Items[0] as DteqModel;
  
          if (CheckCircularReference(Dteq, Dteq.FedFrom)) {
              return new ValidationResult(false, &quot;Equipment cannot be fed from itself&quot;);
          }
  
          return new ValidationResult(true, null);
      }
  </code></pre>
  <p>This is applied as a RowValidaiton on a DataGrid and it's working but not 100% as expected.
  <strong>Dteq.FedFrom</strong> is a combobox, and the the validation acts on the previous value in the row/cells, not the values I currently entered after RowEndEdit. It appears the validation is done before the values are saved to the actual collection object. I am using NotifyProperty changed on all objects and the collection in the datagrid is an observable collection.</p>
  <pre><code>DteqModel Dteq = (value as BindingGroup).Items[0] 
  </code></pre>
  <p>How do I get the above line to read the data as it is currently in the row? Right now if I enter an invalid result, I have to enter edit mode twice for the failed validation to take effect. And after that, I can't change it back to anything valid because it always results in a failed validation and won't update the value.</p>
  <p>For reference <strong>CheckCircularReference</strong> just checks to see if <strong>Dteq.Tag == Dteq.FedFrom</strong>, either directly or through the full tree of parent/child relationship.</p>
  <pre><code>private bool CheckCircularReference(DteqModel startDteq, string nextDteq, int counter =1) {
          var dteqDict = Dictionaries.dteqDict;
          if (nextDteq == &quot;&quot; &amp; counter == 1) { // sets the initial FedFrom
              nextDteq = startDteq.FedFrom;
          }
  
          if (dteqDict.ContainsKey(nextDteq) == false || nextDteq == &quot;&quot; || counter &gt; dteqDict.Count) { // all equipment has been checked
              return false;
          }
          else if (startDteq.FedFrom == startDteq.Tag) { // if the equipment is fed from itself
              return true;
          }
          else if (dteqDict.ContainsKey(nextDteq)) {
              if (dteqDict[nextDteq].FedFrom == startDteq.Tag) { // if the equipment is indirectly fed from itself
                  return true;
              }
              counter += 1;
              return CheckCircularReference(startDteq, dteqDict[nextDteq].FedFrom, counter); // if not increase the count and check the next Equipment
          }
          
          return false;
      }
  </code></pre>
  <p>Thanks in advance.</p>