title: XAML Data Binding not updating UI when property changes
body: <p>I'm having trouble getting a simple data bound label to update when an integer field is changed. I've implemented INotifyPropertChanged and this event gets fired when I chang my variables value. The UI does not update and the label does not change. I haven't done much data binding in the past so I'm probably missing something but I haven't been able to find it yet.</p>
  
  <p>Here is what I have for my XAML:</p>
  
  <pre><code>         &lt;Window x:Class="TestBinding.MainWindow" 
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                  xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                  xmlns:mc="http://schemas.openxmlformats.org/markup-
                  compatibility/2006"
                  xmlns:local="clr-namespace:TestBinding"
                  mc:Ignorable="d"
                  Title="MainWindow" Height="350" Width="525"&gt;
              &lt;StackPanel&gt;
                  &lt;Button Command="{Binding TestCommand, Mode=OneWay}" &gt;
                      &lt;Button.DataContext&gt;
                          &lt;local:TestVM/&gt;
                      &lt;/Button.DataContext&gt; Add 1&lt;/Button&gt;
                  &lt;Label Content="{Binding Count,
                   Mode=OneWay,UpdateSourceTrigger=PropertyChanged}"&gt;
                      &lt;Label.DataContext&gt;
                          &lt;local:TestVM/&gt;
                      &lt;/Label.DataContext&gt;
                  &lt;/Label&gt;
              &lt;/StackPanel&gt;
          &lt;/Window&gt;
  </code></pre>
  
  <p>Here is my View Model C#:</p>
  
  <pre><code>class TestVM : INotifyPropertyChanged
      {
          private int _count;
          private RelayCommand _testCommand;
  
          public TestVM ()
          {
              Count=0;
  
          }
  
          public int Count
          {
              get { return _count; }
              set { _count = value; OnPropertyChanged(); }
          }
  
          public void Test()
          {
              Count++;
          }
  
          public ICommand TestCommand
          {
              get
              {
                  if (_testCommand == null)
                  {
                      _testCommand = new RelayCommand(param =&gt; this.Test(), param =&gt; true);
                  }
  
                  return _testCommand;
              }
          }
  
          public event PropertyChangedEventHandler PropertyChanged;
  
          protected void OnPropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = "")
          {
              if (this.PropertyChanged != null)
              {
                  Console.WriteLine(propertyName);
                  var e = new PropertyChangedEventArgs(propertyName);
                  this.PropertyChanged(this, e);
              }
          }
      }
  </code></pre>
  
  <p>Here is my ICommand C# (In case you need it to replicate what I have):</p>
  
  <pre><code>public class RelayCommand : ICommand
      {
          #region Fields 
          readonly Action&lt;object&gt; _execute;
          readonly Predicate&lt;object&gt; _canExecute;
          #endregion // Fields 
  
          #region Constructors 
          public RelayCommand(Action&lt;object&gt; execute) : this(execute, null) { }
          public RelayCommand(Action&lt;object&gt; execute, Predicate&lt;object&gt; canExecute)
          {
              if (execute == null) throw new ArgumentNullException("execute");
              _execute = execute;
              _canExecute = canExecute;
          }
          #endregion // Constructors 
  
          #region ICommand Members [DebuggerStepThrough] 
          public bool CanExecute(object parameter)
          {
              return _canExecute == null ? true : _canExecute(parameter);
          }
  
          public event EventHandler CanExecuteChanged
          {
              add { CommandManager.RequerySuggested += value; }
              remove { CommandManager.RequerySuggested -= value; }
          }
  
          public void Execute(object parameter)
          {
              _execute(parameter);
          }
          #endregion
          // ICommand Members 
      }
  </code></pre>
  
  <p>Any and all help is greatly appreciated.</p>
  
  <p><strong>EDIT:</strong>
  I updated my xaml to what toadflakz suggested and it worked.</p>
  
  <pre><code>&lt;Window x:Class="TestBinding.MainWindow"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
          xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
          xmlns:local="clr-namespace:TestBinding"
          mc:Ignorable="d"
          Title="MainWindow" Height="350" Width="525"&gt;
      &lt;Window.DataContext&gt;
          &lt;local:TestVM/&gt;
      &lt;/Window.DataContext&gt;
      &lt;StackPanel&gt;
      &lt;Button Command="{Binding TestCommand, Mode=OneWay}" &gt;Add 1&lt;/Button&gt;
      &lt;Label Content="{Binding Count, Mode=OneWay,UpdateSourceTrigger=PropertyChanged}" /&gt;
  &lt;/StackPanel&gt;
  &lt;/Window&gt;
  </code></pre>