title: Show Validation Error in UserControl
body: <p>I am not sure why the validation state doesn't get reflected in my user control.
  I am throwing an exception but for some reason the control doesn't show the validation state...When I use a standard <code>Textbox</code> (Which is commented out right now in my example) on my MainPage it shows the error state, not sure why its not when its wrapped.</p>
  
  <p>I have slimmed this down so basically its a user control that wraps a <code>TextBox</code>.
  What am I missing??</p>
  
  <p>MyUserControl XAML:</p>
  
  <pre><code>&lt;UserControl x:Class="ValidationWithUserControl.MyUserControl"
      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="300" d:DesignWidth="400"&gt;
  
      &lt;Grid x:Name="LayoutRoot" Background="White"&gt;
          &lt;TextBox x:Name="TextBox"/&gt;
      &lt;/Grid&gt;
  &lt;/UserControl&gt;
  </code></pre>
  
  <p>MyUserControl Code Behind:</p>
  
  <pre><code>public partial class MyUserControl : UserControl
  {
      public MyUserControl()
      {
          InitializeComponent();
  
          this.Loaded += new RoutedEventHandler(MyUserControl_Loaded);
          this.TextBox.Unloaded += new RoutedEventHandler(TextBox_Unloaded);
      }
  
      public string Value
      {
          get { return (string)base.GetValue(ValueProperty); }
          set { base.SetValue(ValueProperty, value); }
      }
  
      public static DependencyProperty ValueProperty =
          DependencyProperty.Register(
          "Value",
          typeof(string),
          typeof(MyUserControl),
          new PropertyMetadata(null));
  
      private void MyUserControl_Loaded(object sender, RoutedEventArgs e)
      {
          this.TextBox.SetBinding(TextBox.TextProperty, new Binding()
          {
              Source = this,
              Path = new PropertyPath("Value"),
              Mode = BindingMode.TwoWay,
              ValidatesOnExceptions = true,
              NotifyOnValidationError= true
          });  
      }
  
      private void TextBox_Unloaded(object sender, RoutedEventArgs e)
      {
          this.TextBox.ClearValue(TextBox.TextProperty);
      }
  }
  </code></pre>
  
  <p>My MainPage XAML:</p>
  
  <pre><code>&lt;Grid x:Name="LayoutRoot" Background="LightBlue"&gt;
      &lt;StackPanel&gt;
          &lt;uc:MyUserControl x:Name="UC" Value="{Binding Path=Value, Mode=TwoWay}" Height="20" Width="100" /&gt;
          &lt;!--TextBox x:Name="MS" Text="{Binding Path=Value, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True}" Height="20" Width="100" /--&gt;
      &lt;/StackPanel&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p>My MainPage Code Behind:</p>
  
  <pre><code>public partial class MainPage : UserControl
  {
      private Model model;
      //private Model model2;
  
      public MainPage()
      {
          InitializeComponent();
          this.model = new Model("UC");
          //this.model2 = new Model("MS");
          this.UC.DataContext = this.model;
          //this.MS.DataContext = this.model2;
      }
  }
  </code></pre>
  
  <p>My Model:</p>
  
  <pre><code>public class Model
  {
      public Model(string answer)
      {
          this.answer = answer;
      }
  
      private string answer;
      public string Value
      {
          get
          {
              return this.answer;
          }
          set
          {
              if (!String.IsNullOrEmpty(value))
                  this.answer = value;
              else
                  throw new Exception("Error");
          }
      }
  }
  </code></pre>