title: WPF TextBox databinding, works only partially
body: <p>I have a simple WPF textbox that I want to update once when the window is initialized, and then each time a certain event occurs.
  I have followed the instructions in many StackOverflow answers, in particular this one:
  <a href="https://stackoverflow.com/questions/1725554/wpf-simple-textbox-data-binding">WPF: simple TextBox data binding</a>
  So I came up with the following.</p>
  
  <p>In xaml:</p>
  
  <pre><code>&lt;TextBox x:Name="txtFeedback" 
           TextWrapping="Wrap" 
           Text="{Binding Path=FeedbackText, Mode=TwoWay,
                          UpdateSourceTrigger=PropertyChanged}" 
           IsReadOnly="True" 
           AcceptsReturn="True"/&gt;
  </code></pre>
  
  <p>And in the MainWindow:</p>
  
  <pre><code>private string _feedbackText;
  public event PropertyChangedEventHandler PropertyChanged;
  
  public string FeedbackText
  {
      get
      {
          return _feedbackText;
      }
      set
      {
          _feedbackText = value;
          OnPropertyChanged("FeedbackText");
      }
  }
  
  protected void OnPropertyChanged(string propertyName)
  {
      PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  }
  
  public MainWindow()
  {
      InitializeComponent();
      this.DataContext = this;
      FeedbackText = "Awaiting start of process...";
  }
  private void FinishedWorksheet(object sender, EventArgs e)
  {
      FeedbackText += "Done another worksheet" ;
  }
  </code></pre>
  
  <p>When the constructor of the form is called, the textbox correctly displays "Awaiting start of process...", but when I call the FinishedWorksheet method (which is called by some other event) the textbox is not updated.</p>
  
  <p>Please note that if I put breakpoints inside OnPropertyChanged I can see that it is called, and in the immediate window I can see the Text property actually changing, but somehow the textbox is not updated.</p>
  
  <blockquote>
    <p>txtFeedback.Text</p>
    
    <p>"Awaiting start of process...Done another worksheet"</p>
  </blockquote>
  
  <h1>Update</h1>
  
  <p>The problem was much simpler, and sorry to everyone for not posting one fundamental part of the code: <strong>I was doing everything inside the GUI thread!</strong>
  So of course the GUI could not react until I released the thread!
  Once I made the external call Asynchronous, it all works fine.
  Thank you all for your suggestions though, I learned a lot, and I hope others did too.</p>