WP7 Simple Clock小程序
本文将制作一个很简单的Clock
1、添加一个textBlock控件,代码如下:
<TextBlock Name="txtblk" HorizontalAlignment="Center" VerticalAlignment="Center" />
using System.Windows.Threading;
3、编写CS代码
public MainPage()
{
InitializeComponent();
DispatcherTimer tmr = new DispatcherTimer();
tmr.Interval = TimeSpan.FromSeconds(1); //间隔为1秒
tmr.Tick += OnTimerTick;
tmr.Start();
}
void OnTimerTick(object sender, EventArgs args)
{
txtblk.Text = DateTime.Now.ToString();
}


浙公网安备 33010602011771号