changing the text of a label (or sophisticatedly we can say a text-based progress bar). in winforms you just Invalidate / Update.
But how to do this in WPF without using Background Threads. ???
changing the text of a label (or sophisticatedly we can say a text-based progress bar). in winforms you just Invalidate / Update.
But how to do this in WPF without using Background Threads. ???
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);
}
}
Reference: http://geekswithblogs.net/NewThingsILearned/archive/2008/08/25/refresh--update-wpf-controls.aspx