title: Enabling or disabling validation upon context
body: <p><strong>Introduction</strong></p>
  
  <p>I have two <code>TextBox</code> in my view, each binded to some properties in my view-model (<code>Property1</code>, <code>Property2</code>). </p>
  
  <p><code>TextBox</code> are alternatively enabled upon some boolean, and properties, are validated  using <code>IDataErrorInfo</code> in the view-model + some styling in the view.</p>
  
  <p><strong>Problem</strong></p>
  
  <p>I would like to disable validation style when items are disabled.</p>
  
  <p>NB1: Currently, solution I found is to change validation scheme directly in the view-model, but this requires to notify for property changes in order to force the view to re-read <code>IDataErrorInfo</code> (while properties haven't really changed, only selector ...)</p>
  
  <p>NB2: My problem is really close to this <a href="https://stackoverflow.com/q/7123687/684399">one</a>, but the description and the solutions are far too complex for me to really get the point.</p>
  
  <p><strong>Pseudo-Code</strong></p>
  
  <pre><code>&lt;UserControl 
  
      &lt;UserControl.Resources&gt;
          &lt;Style TargetType="{x:Type Control}" x:Key="ControlValidationStyle"&gt;
              ...
          &lt;/Style&gt; 
      &lt;/UserControl.Resources&gt;
  
       ...
  
      &lt;TextBox  
               Text="{Binding Property1, 
                              ValidatesOnDataErrors=True, 
                              UpdateSourceTrigger=PropertyChanged}" 
  
               IsEnabled="{Binding IsMode1}"
  
               Style="{StaticResource ControlValidationStyle}"
       /&gt;
  
      &lt;TextBox  
               Text="{Binding Property2, 
                              ValidatesOnDataErrors=True, 
                              UpdateSourceTrigger=PropertyChanged}" 
  
               IsEnabled="{Binding IsMode1, 
                                   Converter={StaticResource BoolInverse}}"
  
               Style="{StaticResource ControlValidationStyle}"
       /&gt;
  
  &lt;/UserControl&gt;
  </code></pre>
  
  <p><strong>ControlValidationStyle</strong></p>
  
  <pre><code>&lt;Style TargetType="{x:Type Control}" x:Key="ControlValidationStyle"&gt;
      &lt;Style.Resources&gt;
          &lt;Style TargetType="ToolTip"&gt;
              &lt;Setter Property="Background" Value="Tomato" /&gt;
              &lt;Setter Property="BorderBrush" Value="Red" /&gt;
              &lt;Setter Property="BorderThickness" Value="2" /&gt;
              &lt;Setter Property="Foreground" Value="white" /&gt;
          &lt;/Style&gt;
      &lt;/Style.Resources&gt;
      &lt;Style.Triggers&gt;
          &lt;Trigger Property="Validation.HasError" Value="true"&gt;
              &lt;Setter Property="ToolTip" 
                          Value="{Binding RelativeSource={RelativeSource Self},
                          Path=(Validation.Errors)[0].ErrorContent}" /&gt;
              &lt;Setter Property="Background" Value="Bisque"/&gt;
              &lt;Setter Property="BorderBrush" Value="Red" /&gt;
              &lt;Setter Property="BorderThickness" Value="2" /&gt;
              &lt;Setter Property="Foreground" Value="Red" /&gt;
          &lt;/Trigger&gt;
      &lt;/Style.Triggers&gt;
  &lt;/Style&gt;
  </code></pre>