title: Data binding in WPF on button click
body: <p>I am trying to implement data binding, and to have TextBox's text to be update once I click on some button.</p>
  
  <p>XAML:</p>
  
  <pre><code>&lt;TextBox  Text="{Binding Path=Output}" /&gt;
  </code></pre>
  
  <p>Code: </p>
  
  <pre><code>    public MainWindow()
      {
          InitializeComponent();
          DataContext = Search;
          Search.Output = "111";
      }
  
      public SearchClass Search = new SearchClass();
  
  
      private void button1_Click(object sender, RoutedEventArgs e)
      {
          Search.Output = "222";
      }
  
      public class SearchClass
      {
          string _output;
  
          public string Output
          {
              get { return _output; }
              set { _output = value; }
          }
      }
  </code></pre>
  
  <p>When I execute the program, I see "111", so the binding from MainWindow() works, but if I click a button - the text in the TextBox is not updated (but in the debugger I see that button1_Click is executed and Search.Output is now equal to "222"). What am I doing wrong?</p>