title: WPF - MVVM - Textbox getting out of sync with viewmodel property
body: <p>I have a WPF view with a TextBox, binding the Text field to a ViewModel with UpdateSourceTrigger set to PropertyChanged.  In the property setter in the ViewModel, I have a simple check to prevent the text from exceeding 10 characters:</p>
  
  <pre><code>&lt;TextBox Text="{Binding Name, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" /&gt;
  
  public partial class MainWindow : Window
  {
      public MainWindow()
      {
          InitializeComponent();
  
          this.DataContext = new MainViewModel();
      }
  }
  
  
  public string Name
  {
      get { return _Name; }
      set
      {
          if (_Name != value)
          {
              if (value.Length &lt;= 10)
              {
                  _Name = value;
              }
              RaisePropertyChanged("Name");
          }
      }
  }
  </code></pre>
  
  <p>If the value isn't set, I still RaisePropertyChanged (which simply fires PropertyChanged).</p>
  
  <p>The problem is that when I type in the 11th character in the UI, I don't update _Name.  I fire PropertyChanged, and I can see the get accessor get called and it returns the string with only 10 characters.  However, my TextBox doesn't reflect this; it still shows the string with 11 characters.</p>
  
  <p>On top of that, is that if on the 11th character I change the text in the setter to "ERROR", and fire property changed, the TextBox DOES update to show the altered text.</p>
  
  <p>So why is it that if I alter the text in the setter back to the previous value, the UI doesn't reflect this?</p>
  
  <p>I know there are alternative ways of handling max characters, but why won't this work?</p>