时间(年月日)
xaml
<Label x:Name="DatePic" Grid.Column="1" HorizontalAlignment="Left" FontSize="10" VerticalAlignment="Bottom" Margin="97,0,0,8" Height="25" Width="106"/>
xaml.cs
#region 实时刷新日历
private void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
//UI异步更新
this.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() =>
{
updateDatePic();
}));
}
private void DatePicInit()
{
timer = new System.Timers.Timer(1000);
timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
timer.Start();
}
private void updateDatePic()
{
DatePic.Content = DateTime.Now.ToString("yyyy/MM/dd");
}
#endregion
private void MenuItem_ClickTest(object sender, RoutedEventArgs e)
{
WinTest test = new WinTest();
test.Owner = DataWinMan.m_winHostEnc;
test.Show();
}