如何在WPF中显示标签几秒钟? [英] how to show label for couple of seconds in wpf?
本文介绍了如何在WPF中显示标签几秒钟?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只想显示一个标签3秒钟,然后消失. 我正在使用wpf应用程序.
i want to show a label for a 3 seconds only and then disappear it. i am working in wpf application.
public DispatcherTimer timer = new DispatcherTimer();
timer.Tick += new EventHandler(timer_Tick);
我从该功能启动了计时器
i started timer from the function
timer.Start();
private void timer_Tick(object sender, EventArgs e)
{
/*
if timer equals 3 seconds then
timer.stop();
lblToast.Visibility = Visibility.Hidden;
else
lblToast.Visibility = Visibility.Visible;
*/
}
这是正确的方法吗? 还是有其他简单的方法吗?
is this right way ? or is there any other easy way ?
推荐答案
将Interval
设置为3000,然后将标签隐藏在Tick
事件中.
Set your Interval
to 3000 and then just hide the label in the Tick
event.
这篇关于如何在WPF中显示标签几秒钟?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文