title: Bound Textbox Not Updating on Change in Codebehind
body: <p>I copied this code from another project and can't figure out why it isn't working.  My observable collections are working great binding and updating, but my textboxes aren't changing.  I have a button click that lets the user pick a directory (<code>DirectoryBrowse()</code> method) and then assigns that value to the data context's property that is bound to the textbox.  <code>PropertyChanged</code> is always null and I can't figure out why!  The initial binding works just fine, just note when I change the value in the code-behind.  I've been at this entirely too long, but any help would be appreciated!</p>
  
  <p><code>DataContext</code> class:</p>
  
  <pre><code>[Serializable]
  public class Settings : ViewModels.ViewModelEntity
  {
      public static Settings defaultSettings { get; set; }
  
      private string _ExportDir;
      public string ExportDir
      {
          get { return this._ExportDir; }
          set
          {
              if (this._ExportDir != value)
              {
                  this._ExportDir = value;
                  this.NotifyPropertyChanged("ExportDir");
              }
          }
      }
  
      private string _LastRunTime;
      public string LastRunTime
      {
          get { return this._LastRunTime; }
          set
          {
              if (this._LastRunTime != value)
              {
                  this._LastRunTime = value;
                  this.NotifyPropertyChanged("LastRunTime");
              }
          }
      }
  
      private string _TSCertPath;
      public string TSCertPath
      {
          get { return this._TSCertPath; }
          set
          {
              if (this._TSCertPath != value)
              {
                  this._TSCertPath = value;
                  this.NotifyPropertyChanged("TSCertPath");
              }
          }
      }
  
      public ObservableCollection&lt;Map&gt; Brokers { get; set; }
      public ObservableCollection&lt;Account&gt; Accounts { get; set; }
  
      public List&lt;Holiday&gt; Holidays { get; set; }
      public bool RefreshHolidays { get; set; }
      public string ProxyServer { get; set; }
      public string ProxyPort { get; set; }
      public string ProxyUsername { get; set; }
      public string ProxyPassword { get; set; }
      public bool TSProd { get; set; }
      public string TSTriad { get; set; }
      public string TSPassword { get; set; }
      public string TSCertPassword { get; set; }
  
      public Settings()
      {
          this.Brokers = new ObservableCollection&lt;Map&gt;();
          this.Accounts = new ObservableCollection&lt;Account&gt;();
      }
  }
  </code></pre>
  
  <p>Xaml:</p>
  
  <pre><code>&lt;TextBlock TextWrapping="Wrap" Text="File Export Path*"/&gt;
  &lt;TextBox TextWrapping="Wrap" Text="{Binding Path=ExportDir, Mode=TwoWay}" /&gt;
  &lt;Button x:Name="btnBrowseExportDir" Content="..." Click="btnBrowseExportDir_Click"/&gt;
  </code></pre>
  
  <p>Code-behind:</p>
  
  <pre><code>public MainWindow()
  {
      InitializeComponent();
      Settings.Initialize();
      this.DataContext = Settings.defaultSettings;
  
      string[] args = Environment.GetCommandLineArgs();
  
      if (args.Contains("create"))
      {
          this.Close();
      }
  }
  
  private string DirectoryBrowse()
  {
      CommonOpenFileDialog dialog = new CommonOpenFileDialog();
      dialog.IsFolderPicker = true;
      CommonFileDialogResult result = dialog.ShowDialog();
  
      if (result.ToString().ToUpper() == "OK")
      {
          if (!Directory.Exists(dialog.FileNames.First()))
          {
              this.lblStatus.Text = "Invalid directory selected";
              return string.Empty;
          }
          else
          {
              return dialog.FileNames.First();
          }
      }
      else
      {
          this.lblStatus.Text = "Invalid directory selected";
          return string.Empty;
      }
  }
  
  private void btnBrowseExportDir_Click(object sender, RoutedEventArgs e)
  {
      Settings.defaultSettings.ExportDir = DirectoryBrowse();
  }
  </code></pre>
  
  <p><code>ViewModelEntity</code>:</p>
  
  <pre><code>public class ViewModelEntity
  {
      public event PropertyChangedEventHandler PropertyChanged;
  
      public virtual void NotifyPropertyChanged(string propertyName)
      {
          if (PropertyChanged != null)
          {
              PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
          }
      }
  }
  </code></pre>