the code below works in Windows Phone 7
private void ShowTime()
{
txtTime.Text = get24hour();
//display the Date and week.
DateTime nowtime = DateTime.Now;
txtWeek.Text = nowtime.DayOfWeek.ToString();
txtDate.Text = nowtime.Date.ToString("MM/dd");
//create timer to fresh to time
DispatcherTimer timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromMinutes(1);
timer.Tick += timer_Ticker;
timer.Start();
}
private void timer_Ticker(object sender, EventArgs e)
{
txtTime.Text = get24hour();
}
private string get24hour()
{
return DateTime.Now.ToString("HH:mm");
}
but error in WinRT (Metro)
error part:
timer.Tick += timer_Ticker;
error message:
No overload for 'timer_Ticker' matches delegate 'System.EventHandler<object>'
what I do
I try to change the code to
private void timer_Ticker()
{
txtTime.Text = get24hour();
}
result
but it is not work again, why and how to solve it? 🙁
Refer to this link