silverlight的timer

silverlight的timer跟winform和asp.net的timer用法基本没什么难度,首先你得新建一个DispatcherTimer对象,然后再设置DispatcherTimer几秒tick一次

然后再写tick时间

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

 DispatcherTimer类在System.Windows.Threading;命名空间下。

然后就是timer_Tick()方法

void timer_Tick(object sender, EventArgs e)
        {
            textblock.Text = "当前的时间是:" + DateTime.Now.ToString(); ;
        }

 时间就被设置为一秒跳转一次,就可以显示当前的时间了

原文地址:https://www.cnblogs.com/lihaozhou/p/2611093.html