title: Updating dynamically the content property of a label with the WPF user model
body: <p>A simple WPF window with a label on it:</p>
  
  <pre><code>&lt;Window x:Name="MainWindow1" x:Class="WpfApplication1.MainWindow"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          xmlns:A="clr-namespace:WpfApplication1"
          xmlns:System="clr-namespace:System;assembly=mscorlib"
          Title="MainWindow" Height="384" Width="669.114" Icon="alarmclock.ico" Closing="OnClosing" Loaded="OnLoaded" &gt;
      &lt;Grid x:Name="Grid1"&gt;
          &lt;Label x:Name="Label1" Content="{Binding AlarmStatus}" HorizontalAlignment="Left" Margin="10,314,0,0" VerticalAlignment="Top"/&gt;  
      &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p>Wire up an object so that the object can be bound to the labels content property. Yes I see the text Off on the window:</p>
  
  <pre><code>public class PropertyChangedBase : INotifyPropertyChanged
  {
      public event PropertyChangedEventHandler PropertyChanged;
  
      protected virtual void OnPropertyChanged(string propertyName)
      {
          //Raise the PropertyChanged event on the UI Thread, with the relevant propertyName parameter:
          Application.Current.Dispatcher.BeginInvoke((Action)(() =&gt;
          {
              PropertyChangedEventHandler handler = PropertyChanged;
              if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
          }));
      }
  }
  
  public class UserViewModel : PropertyChangedBase
  {
      private string _alarmStatus = "Off";
  
      public string AlarmStatus
      {
          get { return _alarmStatus; }
          set
          {
              _alarmStatus = value;
              OnPropertyChanged("AlarmStatus"); //This is important!!!
          }
      }
  }
  
  /// &lt;summary&gt;
  /// Interaction logic for MainWindow.xaml
  /// &lt;/summary&gt;
  public partial class MainWindow : Window
  </code></pre>
  
  <p>I thought I would be able to change the value of the label like this:</p>
  
  <pre><code>private void OnLoaded(object sender, RoutedEventArgs e)
  {
      //Im setting a value but the UI does not change. The label still says Off
      UserViewModel aaaa = new UserViewModel();
      aaaa.AlarmStatus = "On";
  }
  </code></pre>