title: c# wpf MVVM textbox update
body: <p>I'd like some help with my test project. I'd like when I press one of my buttons and the letter consists in the hidden word at the textbox(hangman) to update the textbox with the revealed letter/s. Currently my logic with the guessing works but the textbox won't update. </p>
  
  <pre><code>MainWindow.xaml:
  &lt;Window x:Class="test.MainWindow"
      xmlns:vm="clr-namespace:test.ViewModel"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      Title="MainWindow" Height="350" Width="525"&gt;
  
  &lt;Window.DataContext&gt;
      &lt;vm:MainWindowViewModel /&gt;
  &lt;/Window.DataContext&gt;
  
  &lt;Grid&gt;
      &lt;Grid.RowDefinitions&gt;
          &lt;RowDefinition Height="59*"/&gt;
          &lt;RowDefinition Height="55*"/&gt;
          &lt;RowDefinition Height="68*"/&gt;
          &lt;RowDefinition Height="65*"/&gt;
          &lt;RowDefinition Height="72*"/&gt;
      &lt;/Grid.RowDefinitions&gt;
      &lt;Grid.ColumnDefinitions&gt;
          &lt;ColumnDefinition Width="13*"/&gt;
          &lt;ColumnDefinition Width="34*"/&gt;
      &lt;/Grid.ColumnDefinitions&gt;
      &lt;Button Grid.Column="0" Grid.Row="0" Command="{Binding ButtonClick}" CommandParameter="a"&gt;
          a
      &lt;/Button&gt;
      &lt;Button Grid.Column="0" Grid.Row="1" Command="{Binding ButtonClick}" CommandParameter="b"&gt;
          b
      &lt;/Button&gt;
      &lt;Button Grid.Column="0" Grid.Row="2" Command="{Binding ButtonClick}" CommandParameter="c"&gt;
          c
      &lt;/Button&gt;
      &lt;Button Grid.Column="0" Grid.Row="3" Command="{Binding ButtonClick}" CommandParameter="d"&gt;
          d
      &lt;/Button&gt;
      &lt;Button Grid.Column="0" Grid.Row="4" Command="{Binding ButtonClick}" CommandParameter="e"&gt;
          e
      &lt;/Button&gt;
      &lt;TextBox Text="{Binding Path=DisplayWordInTextbox, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Grid.Column="1" Grid.Row="2"/&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p></p>
  
  <p>MainWindowViewModel.cs:</p>
  
  <pre><code>class MainWindowViewModel : INotifyPropertyChanged
  {
      private string displayWordInTextbox;
      public string DisplayWordInTextbox
      {
          get
          {
              return displayWordInTextbox;
          }
          set
          {
              displayWordInTextbox = value;
              NotifyPropertyChanged("DisplayWordInTextbox");
          }
      }
  
      public MainWindowViewModel()
      {
          buttonClick = new RelayCommand(buttonFunction);
          loadWordsFromFile();
          selectWord();
          displayWord();
      }
  
      public event PropertyChangedEventHandler PropertyChanged;
      private void NotifyPropertyChanged([CallerMemberName] String propName = "")
      {
          if (PropertyChanged != null)
          {
              PropertyChanged(this, new PropertyChangedEventArgs(propName));
          }
      }
  }
  </code></pre>