title: WPF MVVM Validation DataGrid and disable CommandButton
body: <p>I have created a sample MVVM application attached. </p>
  
  <ul>
  <li>I use a datagrid</li>
  <li>I have a button bound to a command</li>
  <li>I have a some custom validation rules applied to certain cells and a textbox.  </li>
  </ul>
  
  <p>What I want to achieve is: </p>
  
  <ul>
  <li>I like validating while typing (this is already working with validation rules and UpdateSourceTrigger=PropertyChanged). </li>
  <li><p>I'd like to validate single cells/rows (this is already working, too)</p></li>
  <li><p>I'd like to do "form" validation. E.g. Cross-row validation to validate that no duplicate strings are in the first column of the datagrid.</p></li>
  <li>I'd like to disable the command if any validation rule has or the viewmodels form validation has an error. </li>
  <li>I'd like to enable the command if the form is valid. </li>
  </ul>
  
  <p>How would you do this? I have no clue how to implement the form validation in the view model. </p>
  
  <p>My first idea was just to call a validation method on the viewmodel from the code behind every time anything changes. But doing so, I still don't know how to inform the viewmodel about an validation error in the view's validation rule (e.g. if someone enters text to the ID column). The viewmodel would simply not know about it and eventually validate successfully, just because the wrong value never reaches it. Ok, I could use strings and do the whole conversion in the viewmodel - but I don't like this idea, because I would like to use the whole power of the converters/validators in WPF. </p>
  
  <p>Has anybody already done something like that? </p>
  
  <p><a href="https://www.dropbox.com/s/f3a1naewltbl9yp/DataGridValidationTest.zip?dl=0" rel="nofollow">https://www.dropbox.com/s/f3a1naewltbl9yp/DataGridValidationTest.zip?dl=0</a></p>