1.wpf创建时间
DispatcherTimer dispatcherTimer = new DispatcherTimer();
// 当间隔时间过去时发生的事件
dispatcherTimer.Tick += new EventHandler(ShowCurrentTime);
dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 1);
dispatcherTimer.Start();
public void ShowCurrentTime(object sender, EventArgs e)
{
//获得时分秒
this.tBlockTime.Text = DateTime.Now.ToString("yyyy年MM月dd日 HH:mm:ss");
}