add clock

This commit is contained in:
nguyentien.work410@gmail.com
2025-03-18 17:25:02 +07:00
parent df5249fedc
commit 7ee24657e8
3 changed files with 71 additions and 1 deletions
+42
View File
@@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Threading;
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 SafeBagDE70
{
/// <summary>
/// Interaction logic for ClockUC.xaml
/// </summary>
public partial class ClockUC : UserControl
{
private DispatcherTimer _timer;
public ClockUC()
{
InitializeComponent();
_timer = new DispatcherTimer()
{
Interval = TimeSpan.FromSeconds(1)
};
_timer.Tick += Timer_Tick;
_timer.Start();
}
private void Timer_Tick(object sender, EventArgs e)
{
txtTime.Text = DateTime.Now.ToString("HH:mm:ss");
txtDate.Text = DateTime.Now.ToString("dd/MM/yyyy");
}
}
}