小编Dha*_*val的帖子

如何在wpf中显示标签几秒钟?

我只想显示一个标签3秒钟,然后消失。我在WPF应用程序中工作。

public DispatcherTimer timer = new DispatcherTimer(); 
timer.Tick += new EventHandler(timer_Tick);
Run Code Online (Sandbox Code Playgroud)

我从功能启动计时器

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;
      */
}
Run Code Online (Sandbox Code Playgroud)

这是正确的方法吗?还是还有其他简单的方法?

c# wpf dispatchertimer

1
推荐指数
1
解决办法
1807
查看次数

标签 统计

c# ×1

dispatchertimer ×1

wpf ×1