Updating / updating WPF controls such as win forms

changing the label text (or complex, we can say that the progress bar is based on text). in winforms you are just Invalidate / Update.

But how to do it in WPF without using background threads. ???

+1
source share
2 answers
    public static class ExtensionMethods
{

   private static Action EmptyDelegate = delegate() { };


   public static void Refresh(this UIElement uiElement)
   {
      uiElement.Dispatcher.Invoke(DispatcherPriority.Render, EmptyDelegate);
   }
}

private void LoopingMethod()
{
   for (int i = 0; i < 10; i++)
   {
      label1.Content = i.ToString();
      label1.Refresh();
      Thread.Sleep(500);
   }
}

Link: http://geekswithblogs.net/NewThingsILearned/archive/2008/08/25/refresh--update-wpf-controls.aspx

+8
source

Perhaps you should learn more about the topic of Bindings ..

Mostly bindings will manage this for you.

+4
source

All Articles