我想每秒刷新TextBox数字时钟(Windows App)

Moe*_*gha 1 c# xml window windows-phone-7

C#代码

TextTime.Text = DateTime.Now.ToString();
Run Code Online (Sandbox Code Playgroud)

想要每秒刷新此文本框

或者展示数字时钟任何想法

Cle*_*ens 5

您可以使用DispatcherTimer:

var timer = new DispatcherTimer
{
    Interval = TimeSpan.FromSeconds(1.0)
};
timer.Tick += (o, e) =>
{
    TextTime.Text = DateTime.Now.ToString();
};
timer.Start();
Run Code Online (Sandbox Code Playgroud)