title: wpf DataTrigger values not updating
body: <p>I am trying to make a simple Unity Standalone build launcher (for an arcade cabinet) - the setup is super-simple - joystick up and down highlights a game (in this case changing the fill colour of a rectangle and button1 lauches the correct game. 
  I foolishly thought I could do this simply in wpf, but have stumbled at the first hurdle. </p>
  
  <p>I have the keyboard input (the arcade joystick is setup through an i-pac2) working (focus lock on the mainwindow) and am changing an integer from 0-6. this works (hurray) through code on the MainWindow and is passed to a static int called <em>position</em>.</p>
  
  <p>I then intend to have a series of rectangles that highlight based on this int value. 
  I have been testing on a single rectangle - using dataTrigger to enact the change of state -but it doesn't update on the keyboard input. 
  code snips...</p>
  
  <pre><code>  &lt;Rectangle x:Name="gameRect01" Height="74" Margin="10,93,32.667,0" VerticalAlignment="Top" Grid.ColumnSpan="2" IsEnabled="False"&gt;
          &lt;Rectangle.DataContext&gt;
              &lt;local:Launcher/&gt;
          &lt;/Rectangle.DataContext&gt;
          &lt;Rectangle.Style&gt;
              &lt;Style TargetType="Rectangle"&gt;
                  &lt;Setter Property="Fill" Value="Red" /&gt;
                  &lt;Style.Triggers&gt;
                      &lt;DataTrigger Binding="{Binding Path = cursorPos, NotifyOnSourceUpdated=True, UpdateSourceTrigger=PropertyChanged}" Value="1"&gt;
                          &lt;Setter Property="Fill" Value="Green" /&gt;
                      &lt;/DataTrigger&gt;
                  &lt;/Style.Triggers&gt;
              &lt;/Style&gt;
          &lt;/Rectangle.Style&gt;
  </code></pre>
  
  <p>and the Launcher class...</p>
  
  <pre><code>    using System;
      using System.Collections.Generic;
      using System.Linq;
      using System.Text;
      using System.Threading.Tasks;
      using System.Diagnostics;
      using System.ComponentModel;
  
      namespace GameLauncher 
      {
        class Launcher : INotifyPropertyChanged
        {
          public static int position = 0;
  
      public int cursorPos
      {
          get 
          { return position; 
          }
          set
          {
              cursorPos = position;
              RaisePropertyChanged("cursorPos");
          }
      }
  
  
      public event PropertyChangedEventHandler PropertyChanged;
  
      public virtual void RaisePropertyChanged(string propertyName)
      {
          PropertyChangedEventHandler handler = PropertyChanged;
          if (handler != null)
          {
              var e = new PropertyChangedEventArgs(propertyName);
              handler(this, e);
          }
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>The XAML code seems to be binding with <em>cursorPos</em> - if I change the value in the binding, the rectangle changes fill.</p>
  
  <p>The keyboard input is definitely changing the value of <em>position</em> but the value is not updating inside <em>cursorPos</em>.</p>
  
  <p>I feel I'm missing something extremely simple, but cannot find anything that helps (I've been searching and trying attempting revisions over the last 3 nights without luck). I would really appreciate some pointers for someone new to this.</p>
  
  <p>Thanks,
  Peter</p>
  
  <p><strong>Update</strong>
  I've updated the Launcher based on the feedback below to...</p>
  
  <pre><code>namespace GameLauncher 
  {
  class Launcher : INotifyPropertyChanged
  {
      private int _position;
  
      public int cursorPos
      {
          get {
              return _position;
          }
          set {
              _position = value;
              RaisePropertyChanged(nameof(cursorPos));
          }
      }
  
  
      public event PropertyChangedEventHandler PropertyChanged;
  
      public virtual void RaisePropertyChanged(string propertyName)
      {
          PropertyChangedEventHandler handler = PropertyChanged;
          if (handler != null)
          {
              var e = new PropertyChangedEventArgs(propertyName);
              handler(this, e);
          }
      }
  </code></pre>
  
  <p>and my keyboard input code looks like this...</p>
  
  <pre><code>namespace GameLauncher
  { 
  public partial class MainWindow : Window
  {
      Launcher launcher = new Launcher();
      private string gameGet;
  
  
      public MainWindow()
      {
          InitializeComponent();
          this.KeyDown += new KeyEventHandler(OnButtonKeyDown);
  
      }
  
      public void OnButtonKeyDown(object sender, KeyEventArgs e)
      {
          if (e.Key == Key.Down || e.Key == Key.F) {
              launcher.cursorPos =  Math.Min(6, launcher.cursorPos + 1); Debug.WriteLine(launcher.cursorPos);
          }
  
          if (e.Key == Key.Up || e.Key == Key.R) {
              launcher.cursorPos = Math.Max(0, launcher.cursorPos - 1); Debug.WriteLine(launcher.cursorPos);
          }
  
          if (e.Key == Key.LeftCtrl || e.Key == Key.LeftAlt || e.Key == Key.A || e.Key == Key.S || e.Key == Key.D1 || e.Key == Key.D2){
           //   gameGet = "testGame";
          }
  
      }
  
      private void PlayButton_Click(object sender, RoutedEventArgs e)
      {
        //  Launcher.PlayGame("test");
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>XAML code is the same, but its not updating - gah. The only thing I can think of now is that by instantiating the Launcher class to call in MainWindow isn't correct and I should be doing it another way? </p>