AZ_*_*AZ_ 1 c# wpf invalidation winforms
更改标签的文本(或者我们可以说是基于文本的进度条).在winforms中你只是无效/更新.
但是如何在不使用后台线程的情况下在WPF中执行此操作.???
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);
}
}
Run Code Online (Sandbox Code Playgroud)
参考:http://geekswithblogs.net/NewThingsILearned/archive/2008/08/25/refresh--update-wpf-controls.aspx
归档时间: |
|
查看次数: |
5242 次 |
最近记录: |