C# WPF程序 显示时间
例子来源于此视频https://www.bilibili.com/video/av1422127?p=4
此例子是想说明有的类主要使用它的事件
namespace Wpf_test { /// <summary> /// MainWindow.xaml 的交互逻辑 /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); DispatcherTimer timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromSeconds(1); timer.Tick += Timer_Tick; timer.Start(); } private void Timer_Tick(object sender, EventArgs e) { textBox.Text = DateTime.Now.ToString(); } } }
程序:Wpf_test.zip