Force a WPF control to refresh?

The way to make controls live update in WPF is by TwoWay databinding. So make sure all the viewModel properties you bind to are Dependency Properties or implement INotifyPropertyChanged (and handled correctly) and also that their Binding.Mode = TwoWay.

Check out Rudi Grobler's 10 things I didn't know about WPF data binding

Some databinding articles:

  1. WPF Data Binding - Part 1 By Joel Ivory Johnson alt text
  2. Moving Toward WPF Data Binding One Step at a Time By Josh Smith


Thread thread = new Thread(new ThreadStart(delegate()
                {
                    Thread.Sleep(200); // this is important ...
                    try
                    {
                        this.Dispatcher.BeginInvoke(DispatcherPriority.Send,
                            new NoArgsHandle(delegate()
                            {
                               // do something, set .Text = "some text"
                            }));
                    }
                    catch { }
                }));
                thread.Name = "thread-UpdateText";
                thread.Start();

It works well.


This works for us without the need to create a new thread. It schedules the action to start when all of the bindings have updated themselves first.

           Application.Current.Dispatcher.BeginInvoke(
                DispatcherPriority.Background,
                new Action(() =>
                    {
                        // Do something here.
                    }));