title: wpf - validation - how to show tooltips and disable "run" button
body: <p>Hi
  I need to validate some of textboxes in my application. I decied to use validation rule 
  "DataErrorValidationRule". That's why in my class I implemented IDataErrorInfo interface and wrote aproperiate functions. In my xaml code I added bindings and validation rules to textboxes</p>
  
  <pre><code> &lt;TextBox x:Name="txtName" Grid.Column="3" Grid.Row="1"  TextAlignment="Center" &gt;
                          &lt;TextBox.Text&gt;
                              &lt;Binding Path="Name" &gt;
                                  &lt;Binding.ValidationRules&gt;
                                      &lt;DataErrorValidationRule&gt;&lt;/DataErrorValidationRule&gt;
                                  &lt;/Binding.ValidationRules&gt;
                              &lt;/Binding&gt;
                          &lt;/TextBox.Text&gt;
                      &lt;/TextBox&gt;
  </code></pre>
  
  <p>Validation of this textbox is OK - I mean red frame appears on textbox if data is wrong. However what I need to do is to show tooltip on that textbox, but what is more important I have to disable button "Run" if any textboxes have wrong data. What is the best way to do taht ??</p>
  
  <p>EDIT
  First problem was solved, but I have an another. I need to use MultiBindings to validate my Button. So I did sth like that</p>
  
  <pre><code> &lt;Button x:Name="btnArrange"  Grid.Column="0"  Content="Rozmieść" Click="btnArrange_Click" &gt;
                  &lt;Button.Style&gt;
                      &lt;Style TargetType="Button"&gt;
                          &lt;Style.Triggers&gt;
                              &lt;DataTrigger Value="False"&gt;
                                  &lt;DataTrigger.Binding&gt;
                                      &lt;MultiBinding Converter="{StaticResource BindingConverter}"&gt;
                                          &lt;Binding ElementName="txtName" Path="Validation.HasError" /&gt;
                                          &lt;Binding ElementName="txtSurname" Path="Validation.HasError"/&gt;
                                          &lt;Binding ElementName="txtAddress" Path="Validation.HasError"/&gt;
  
                                      &lt;/MultiBinding&gt;
                                  &lt;/DataTrigger.Binding&gt;
                                  &lt;Setter Property="IsEnabled" Value="False"/&gt;
  
                              &lt;/DataTrigger&gt;
                          &lt;/Style.Triggers&gt;
                      &lt;/Style&gt;        
                  &lt;/Button.Style&gt;
  
          &lt;/Button&gt;
  </code></pre>
  
  <p>My Converter looks like that</p>
  
  <pre><code> public  class Converters : IMultiValueConverter
  {
  
      #region IMultiValueConverter Members
  
      public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
      {
          if(values !=null &amp;&amp; values.Length &gt; 0)
          {
  
  
              if (values.Cast&lt;type&gt;().Count(val =&gt; val) &gt; 0)
                  return false;
              return true;
          }
          return false;
      }
  
      public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
      {
          return null;
      }
  
      #endregion
  }
  </code></pre>
  
  <p>However I get invalidCastException in this converter. What is a proper cast in that case? I thoght as if HasError is a bool type so I should cast to bool.</p>