title: WPF Validation not fired
body: <p>I have a simple textbox and a button on a WPF form. When I click the button an OpenFolderDialog opens and I choose a folder. That SelectedPath is then shown in the textbox. This all works fine.</p>
  
  <p>Then I decided I wanted validation on the textbox to check if the directory exists, because you can just paste some path in the textbox too.
  When my program starts the textbox shows a red border around it because the validation sees an empty textbox. For now I can live with that.</p>
  
  <p>There are two problems:</p>
  
  <ol>
  <li> When I select a valid folder through the dialog, the PropertyChnged is fired, but is null and thus the validation never runs and the red border is still shown.
  <li> When I just paste a valid directory in it, nothing is fired at all and the red border is still shown.
  </ol>
  
  <p>What am I doing wrong?</p>
  
  <p>Below my code. I'm new to WPF so I appreciate every help I can get.</p>
  
  <pre><code>&lt;TextBox Grid.ColumnSpan="2" Grid.Row="1" x:Name="textBoxFolder" Margin="2,4"&gt;
    &lt;TextBox.Text&gt;
      &lt;Binding Path="this.MovieFolder" UpdateSourceTrigger="PropertyChanged"&gt;
        &lt;Binding.ValidationRules&gt;
          &lt;!--  Validation rule set to run when binding target is updated. --&gt;
          &lt;Rules:MandatoryInputRule ValidatesOnTargetUpdated="True" /&gt;
        &lt;/Binding.ValidationRules&gt;
      &lt;/Binding&gt;
    &lt;/TextBox.Text&gt;
  &lt;/TextBox&gt;
  </code></pre>
  
  <p>And here is my c# code:</p>
  
  <pre><code>public partial class MainWindow : Window, INotifyPropertyChanged
  {
    private string _movieFolder;
    public string MovieFolder
    {
      get { return _movieFolder; }
      set
      {
        _movieFolder = value;
        OnNotifyPropertyChanged("MovieFolder");
      }
    }
  
    public MainWindow()
    {
      InitializeComponent();
      //textBoxFolder.DataContext = MovieFolder;
  
    }
  
  
    public event PropertyChangedEventHandler PropertyChanged;
    private void OnNotifyPropertyChanged(string propertyName)
    {
      if (PropertyChanged != null)
      {
        PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
      }
    }
  
    private void buttonSearchFolder_Click(object sender, RoutedEventArgs e)
    {
      FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();
      folderBrowserDialog.ShowDialog();
  
      MovieFolder = folderBrowserDialog.SelectedPath;
      textBoxFolder.Text = MovieFolder;
    }
  
    private void MenuItemClose_Click(object sender, RoutedEventArgs e)
    {
      this.Close();
    }
  
    private void Window_Loaded(object sender, RoutedEventArgs e)
    {
  
    }
  }
  </code></pre>
  
  
  
  <pre><code>public class MandatoryInputRule : ValidationRule
  {
    public override ValidationResult Validate(object value, CultureInfo cultureInfo)
    {
      if (value != null)
      {
        string input = value as string;
  
        if (Directory.Exists(input))
          return new ValidationResult(true, null);
      }
  
      return new ValidationResult(false, "Not a valid folder.");
    }
  }
  </code></pre>