在SilverLight4和Windows Phone 7中可以用DispatcherTimer类实现页面倒计时,这个类的命名空间:System.Windows.Threading

 

 int totalSec = 60;

DispatcherTimer timer = new DispatcherTimer();
timer.Interval = new System.TimeSpan(0, 0, 1);
timer.Tick += new EventHandler(timer_CountDown);
timer.Start();

void timer_CountDown(object sender, EventArgs e)
{
  if (totalSec > 1)
  {
    totalSec--;
    this.btnSubmit.Content = “倒计时”+totalSec ;
  }
  else
  {
     timer.Stop();
  }
}

相关文章:

  • 2022-12-23
  • 2021-10-10
猜你喜欢
  • 2022-12-23
  • 2021-04-29
相关资源
相似解决方案