title: Show Validation Error Template on Controls within a UserControl in WPF
body: <p>How do you get the WPF error template to appear on a control within a UserControl in WPF? </p>
  
  <p>I have a UserControl containing two Labels, two TextBoxes, and a CheckBox. One of the TextBoxes represents the name of the entity and it is bound to a Name property off of a Model property exposed by my ViewModel, which is the DataContext of my Window. The Model class implements the IDataErrorInfo interface and I have confirmed through Unit Testing that when the Name is blank an error is returned through the property indexer implementation. I have bound to the  Dependency Property backing the Name TextBox in my UserControl and when the validation error is encountered the WPF error template places a red border around the entire UserControl rather than just the Name TextBox. </p>
  
  <p>The binding to the name field of the UserControl is as follows.</p>
  
  <pre class="lang-cs prettyprint-override"><code>&lt;vc:MyUserControl ItemName="{Binding Model.Name, ValidatesOnDataErrors=True}" /&gt;
  </code></pre>
  
  <p>A simiplified version of my UserControl  and the backing DependencyProperty is as follows.</p>
  
  <pre class="lang-cs prettyprint-override"><code>&lt;UserControl&gt;
      &lt;Grid&gt;
         &lt;TextBox Text="{Binding ItemName}" /&gt;
      &lt;/Grid&gt;
  &lt;/UserControl&gt;
  
  public partial class MyUserControl: UserControl
  {
      public static readonly DependencyProperty ItemNameProperty = 
          DependencyProperty.Register(
              "ItemName", 
              typeof(string), 
              typeof(MyUserControl), 
              new FrameworkPropertyMetadata(string.Empty, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)
      );
  
      public string ItemName
      {
          get { return (string)GetValue(ItemNameProperty); }
          set { SetValue(ItemNameProperty, value); }
      }
  }
  </code></pre>
  
  <p>The information I have found relating to this issue thus far has all been in regards to Silverlight or using a converter to not show the red border (which did not make sense to me). This information was all found here on stackoverflow.</p>
  
  <p>Has anyone been able to solve this issue with WPF? Am I overlooking something obvious?</p>