【发布时间】:2012-02-21 18:30:07
【问题描述】:
我有一个名为“验证”的按钮。单击时,它的内容应更改为“正在验证...”,处理完成后应显示“已验证”。我们应该如何做到这一点?我是 wpf 的新手。任何帮助将不胜感激。
private void btnVerify_Click(object sender, RoutedEventArgs e)
{
btnVerify.Content = new BitmapImage(new Uri("Verifying.png", UriKind.Relative));
VerifyData(); // this takes almost few seconds to few minutes
btnVerify.Content = new BitmapImage(new Uri("Verified.png", UriKind.Relative));
}
【问题讨论】:
-
你有没有尝试过任何东西,如果有,你能提供代码来说明你卡在哪里吗?
-
private void btnVerify_Click(object sender, RoutedEventArgs e) { btnVerify.Content = new BitmapImage(new Uri("Verifying.png", UriKind.Relative));验证数据(); // 这需要几秒钟到几分钟 btnVerify.Content = new BitmapImage(new Uri("Verified.png", UriKind.Relative)); }
-
@user1222006 - 请下次在您的问题中发布该代码,并使用代码标记(每行开头四个空格)以便于阅读和理解。谢谢。
-
是否所有
VerifyData()代码都在 UI 线程上执行?