我有一个像这样的字符串:
Trump, Defending Himself After Flynn Guilty Plea, Says FBI Is in 'Tatters' | CVS to Buy Aetna for $69 Billion in a Deal that May Reshape the Health Industry | Joy Reid Apologizes for Past Anti-Gay Articles: 'Insensitive, Tone Deaf and Dumb' | California 18-year-old confesses to molesting dozens of children | Bill Belichick Apologizes for Rob Gronkowski's Late Hit, Calls It 'Bulls--t' | Met Opera Suspends James Levine After New Sexual Abuse Accusations | Like it or not, …Run Code Online (Sandbox Code Playgroud) 运行此代码时:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace WpfApplication1
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
while (true)
{
InitializeComponent();
DateTime dtCurrentTime = DateTime.Now;
label1.Content = dtCurrentTime.ToLongTimeString();
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
要经常更新标签,窗口永远不会打开.但是,当我删除while循环时,它可以工作,但它只是不更新标签...那么如何在没有任何用户输入的情况下更新标签以显示当前时间?谢谢,L