title: Show WPF validation error message in a fixed place
body: <p>I got WPF validation running (added <code>ValidationRules</code> to the binding) and with the template I can create nice adorners. There are many posting out there.</p>
  
  <p>But I cannot find a way to display the error message outside of the adorned control in a fixed place like a <code>TextBlock</code> in a corner of the window e.g.</p>
  
  <p>How could I achieve this? Can I bind all of my validation error messages to my <code>DataContext</code> (ViewModel here)?</p>
  
  <hr>
  
  <p>Update: Thanks to an answer I got it partly working. The validation messages are now displayed in another label. As all the textboxes with their validation rules are created on the fly by code, the binding to do so is done this way:</p>
  
  <pre><code>Binding bindSite = new Binding();
  bindSite.Source = this.validationErrorDisplayLabel;
  BindingOperations.SetBinding(textBox, Validation.ValidationAdornerSiteProperty, bindSite);
  </code></pre>
  
  <p>But the validation messages are only forwarded to the <code>adornersite</code> for the last textbox for which this code was executed.</p>
  
  <hr>
  
  <p>I reproduced the problem in this small example.</p>
  
  <p>XAML:</p>
  
  <pre><code>&lt;Grid&gt;
      &lt;TextBox 
          Validation.ValidationAdornerSite="{Binding ElementName=ErrorDisplay}"
          HorizontalAlignment="Left" Height="23" Margin="10,10,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"&gt;
          &lt;TextBox.Text&gt;
              &lt;Binding&gt;
                  &lt;Binding.Path&gt;Box1&lt;/Binding.Path&gt;
                  &lt;Binding.ValidationRules&gt;
                      &lt;local:RuleA /&gt;
                  &lt;/Binding.ValidationRules&gt;
              &lt;/Binding&gt;
          &lt;/TextBox.Text&gt;
      &lt;/TextBox&gt;
      &lt;TextBox 
          Validation.ValidationAdornerSite="{Binding ElementName=ErrorDisplay}"
          HorizontalAlignment="Left" Height="23" Margin="10,38,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"&gt;
          &lt;TextBox.Text&gt;
              &lt;Binding&gt;
                  &lt;Binding.Path&gt;Box2&lt;/Binding.Path&gt;
                  &lt;Binding.ValidationRules&gt;
                      &lt;local:RuleA /&gt;
                  &lt;/Binding.ValidationRules&gt;
              &lt;/Binding&gt;
          &lt;/TextBox.Text&gt;
      &lt;/TextBox&gt;
      &lt;TextBlock 
          x:Name="ErrorDisplay"
          Background="AntiqueWhite"
          Foreground="Red"
          Text="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=(Validation.ValidationAdornerSiteFor).(Validation.Errors)[0].ErrorContent}"
          HorizontalAlignment="Left" Margin="230,10,0,0" TextWrapping="Wrap" VerticalAlignment="Top" RenderTransformOrigin="2.218,-4.577" Width="177" Height="51"/&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p>The class <code>RuleA</code> produces a validation error when the value equals the string <code>"A"</code>. The errors in the 2nd textbox are displayed in the TextBlock, the errors of the first one not (instead it uses the default template and gets a red border).</p>
  
  <p>How can it work for both? The textblock does not need to sum up all errors but display the very first error.</p>