title: How to force validation to show on UserControl
body: <p>I want stock/standard red border validation with tooltip to show around my UserControl. See code below. I have main page and UserControl.</p>
  
  <p>UserControl has textbox and button. UserControls binds to Id property and displays this Id inside TextBox.</p>
  
  <p>Main page has UserControl and TextBox. They bound to FirstValue and SecondValue. Both properties raise error. When I type/change something in textbox - I see border and summary. When I change text in my UserControl - I see error in summary but no border and when I click on error - it focuses button, doesn't go to TextBox. How do I fix that? I want whole UserControl to be inside red border. </p>
  
  <p>MainPage XAML:</p>
  
  <pre><code>&lt;UserControl x:Class="SilverlightApplication1.MainPage"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      mc:Ignorable="d"
      d:DesignHeight="275" d:DesignWidth="402" xmlns:my="clr-namespace:SilverlightApplication1" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"&gt;
  
      &lt;Grid x:Name="LayoutRoot" Background="White" Width="300" HorizontalAlignment="Left"&gt;
          &lt;Grid.RowDefinitions&gt;
              &lt;RowDefinition Height="30" /&gt;
              &lt;RowDefinition Height="40" /&gt;
              &lt;RowDefinition Height="30" /&gt;
              &lt;RowDefinition Height="30" /&gt;
              &lt;RowDefinition Height="*" /&gt;
          &lt;/Grid.RowDefinitions&gt;
          &lt;TextBox Grid.Row="2" Margin="3" Text="{Binding SecondValue, Mode=TwoWay, NotifyOnValidationError=True}"/&gt;
          &lt;my:TestUserControl Margin="3" Id="{Binding FirstValue, Mode=TwoWay, NotifyOnValidationError=True}"/&gt;
          &lt;sdk:ValidationSummary Grid.Row="4" Name="validationSummary1" /&gt;
      &lt;/Grid&gt;
  &lt;/UserControl&gt;
  </code></pre>
  
  <p>MainPage CS</p>
  
  <pre><code>using System.Windows.Controls;
  
  
  namespace SilverlightApplication1
  {
      using System;
      using System.Collections;
      using System.Collections.Generic;
      using System.ComponentModel;
      using System.Linq;
  
      public partial class MainPage : UserControl, INotifyDataErrorInfo, INotifyPropertyChanged
      {
          public event PropertyChangedEventHandler PropertyChanged;
          public event EventHandler&lt;DataErrorsChangedEventArgs&gt; ErrorsChanged;
          readonly Dictionary&lt;string, List&lt;string&gt;&gt; _currentErrors;
  
          private string _firstValue;
          private string _secondValue;
  
          public MainPage()
          {
              InitializeComponent();
              _currentErrors = new Dictionary&lt;string, List&lt;string&gt;&gt;();
              _firstValue = "test1";
              _secondValue = "test2";
              LayoutRoot.DataContext = this;
          }
  
  
          public string FirstValue
          {
              get { return _firstValue; }
  
              set
              {
                  _firstValue = value;
                  CheckIfValueIsValid("FirstValue", value);
                  this.OnPropertyChanged("FirstValue");
              }
          }
  
          public string SecondValue
          {
              get { return _secondValue; }
              set
              {
                  _secondValue = value;
                  CheckIfValueIsValid("SecondValue", value);
                  this.OnPropertyChanged("SecondValue");
              }
          }
  
          public void CheckIfValueIsValid(string propertyName, string value)
          {
              ClearErrorFromProperty(propertyName);
  
              AddErrorForProperty(propertyName, "Bad value");
          }
  
          protected void OnPropertyChanged(string propertyName)
          {
              if (PropertyChanged != null)
              {
                  PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
              }
          }
  
          public IEnumerable GetErrors(string propertyName)
          {
              if (string.IsNullOrEmpty(propertyName))
              {
                  return (_currentErrors.Values);
              }
              MakeOrCreatePropertyErrorList(propertyName);
  
              return _currentErrors[propertyName];
          }
  
          public bool HasErrors
          {
              get
              {
                  return (_currentErrors.Where(c =&gt; c.Value.Count &gt; 0).Count() &gt; 0);
              }
          }
  
          void FireErrorsChanged(string property)
          {
              if (ErrorsChanged != null)
              {
                  ErrorsChanged(this, new DataErrorsChangedEventArgs(property));
              }
          }
  
          public void ClearErrorFromProperty(string property)
          {
              MakeOrCreatePropertyErrorList(property);
  
              _currentErrors[property].Clear();
              FireErrorsChanged(property);
          }
  
          public void AddErrorForProperty(string property, string error)
          {
              MakeOrCreatePropertyErrorList(property);
              _currentErrors[property].Add(error);
              FireErrorsChanged(property);
          }
  
          void MakeOrCreatePropertyErrorList(string propertyName)
          {
              if (!_currentErrors.ContainsKey(propertyName))
              {
                  _currentErrors[propertyName] = new List&lt;string&gt;();
              }
          }
  
  
      }
  }
  </code></pre>
  
  <p>UserControl XAML:</p>
  
  <pre><code>&lt;UserControl x:Class="SilverlightApplication1.TestUserControl"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      mc:Ignorable="d"
      d:DesignHeight="30" d:DesignWidth="400"&gt;
  
      &lt;Grid x:Name="LayoutRoot" Background="White"&gt;
          &lt;Grid.ColumnDefinitions&gt;
              &lt;ColumnDefinition Width="*" /&gt;
              &lt;ColumnDefinition Width="Auto" /&gt;
          &lt;/Grid.ColumnDefinitions&gt;
          &lt;Button Content="..." Grid.Column="1" Padding="10,0" /&gt;
          &lt;TextBox Text="{Binding Id, Mode=TwoWay}" /&gt;
      &lt;/Grid&gt;
  &lt;/UserControl&gt;
  </code></pre>
  
  <p>UserControl CS:</p>
  
  <pre><code>using System.Windows.Controls;
  
  namespace SilverlightApplication1
  {
      using System.ComponentModel;
      using System.Windows;
  
      public partial class TestUserControl : UserControl, INotifyPropertyChanged
      {
          public event PropertyChangedEventHandler PropertyChanged;
  
          public TestUserControl()
          {
              InitializeComponent();
              LayoutRoot.DataContext = this;
          }
  
  
          public string Id
          {
              get { return (string)base.GetValue(IdProperty); }
              set
              {
                  base.SetValue(IdProperty, value);
                  this.OnPropertyChanged("Id");
              }
          }
  
          public static DependencyProperty IdProperty =
              DependencyProperty.Register(
              "Id",
              typeof(string),
              typeof(TestUserControl),
              new PropertyMetadata(OnIdChanged));
  
          private static void OnIdChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
          {
              if (DesignerProperties.IsInDesignTool) return;
  
              var lookup = d as TestUserControl;
              lookup.OnPropertyChanged("Id");
          }
  
          protected void OnPropertyChanged(string propertyName)
          {
              if (PropertyChanged != null)
              {
                  PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
              }
          }
  
      }
  }
  </code></pre>