title: WPF Binding not updating from DispatcherTimer
body: <p>The following is a stripped back version of a problem I'm encountering. It's a fairly common issue, but I'm struggling to find the solution.</p>
  
  <p>I've an instantiated class which I've bound to an item on my main window. This class contains a DispatcherTimer which is used to update a value. In the example given it's incrementing this value by 1 every second.</p>
  
  <p>I'd expect the bound item on my form to reflect this change by updating its value accordingly, however it never updates.</p>
  
  <p>From reading other responses to similar questions on StackOverflow I've a feeling this is due to the nature of the main UI thread running separately to the thread which is causing the increment.</p>
  
  <p>I'm banging my head against a wall though trying to get this binding to update with each call of my DispatcherTimer.</p>
  
  <p>The following is the form element I'm wanting to update every second:</p>
  
  <pre><code>&lt;TextBox Text="{Binding val}" Width="100"/&gt;
  </code></pre>
  
  <p>Next, this is the instantiation of the class containing the timer and my applications configuration:</p>
  
  <pre><code>BasicTimer basictimer;
  public MainWindow()
  {
    InitializeComponent();
    basictimer = new BasicTimer();
    DataContext = basictimer;
  }
  </code></pre>
  
  <p>Lastly, here's the class I've created. When created it configures a timer which it uses to update a value every second. Each time this value is updated I'd expect the main UI to be notified of the change and update accordingly. However, this message doesn't seem to be getting through.</p>
  
  <pre>
    class BasicTimer: INotifyPropertyChanged
    {
      DispatcherTimer _timer;
  
      uint _val = 10;
      public uint val
      {
        get
        {
          return _val;
        }
        set
        {
          if(_val!=value)
          {
            _val = value;
            OnPropertyChanged("Value");
          }
        }
      }
  
      public BasicTimer()
      {
        _timer = new DispatcherTimer();
        _timer.Tick += new EventHandler(TimerTick);
        _timer.Interval = new TimeSpan(0, 0, 1);
        _timer.Start();
      }
  
  
      private void TimerTick(object sender, EventArgs e)
      {
        val++;
        Console.WriteLine(val);
      }
  
      public event PropertyChangedEventHandler PropertyChanged;
  
      protected void OnPropertyChanged(string PropertyName)
      {
        if (PropertyChanged != null)
        {
          PropertyChanged(this, new PropertyChangedEventArgs(PropertyName));
        }
      }
  
  </pre>
  
  <p>I think I've managed to avoid the usual pitfalls of forgetting INotifyPropertChanged, and other bound values from other models are working just fine. It's just this property which is being updated via a thread that I'm having trouble with. I've also tried creating a similar timer using a simple Timer but I'm having the same problem.</p>
  
  <p>Any thoughts would be very much appreciated, thanks!</p>