title: Accessing WPF control validation rules from code
body: <p>XAML:</p>
  
  <pre>
    &lt;TextBox Name="textboxMin">
        &lt;TextBox.Text>
            &lt;Binding Path="Max">
                &lt;Binding.ValidationRules>
                    &lt;local:IntValidator/>
                &lt;/Binding.ValidationRules>
            &lt;/Binding>
        &lt;/TextBox.Text>
    &lt;/TextBox>
  </pre>
  
  <p>Code:</p>
  
  <pre>
  void buttonOK_Click(object sender, RoutedEventArgs e)
  {
      // I need to know here whether textboxMin validation is OK
      // textboxMin. ???
  
      // I need to write something like:
      // if ( textboxMin.Validation.HasErrors )
      //     return;
  }
  </pre>
  
  <p>It would be nice also to know, how to disable OK button, if at least one of dialog controls doesn't pass validation - in XAML, using binding. Having this way, I don't need to check validation state in the code.</p>