I need a simple timer that prints the countdown in a TextBlock in my UWP app. I was suggested to use DispatcherTimer. That's my code.
private void MainButton_Click(object sender, RoutedEventArgs e)
{
dispatcherTimer = new DispatcherTimer();
dispatcherTimer.Tick += DispatcherTimer_Tick;
dispatcherTimer.Interval = new TimeSpan(1000);
dispatcherTimer.Start();
}
private int Seconds;
private void DispatcherTimer_Tick(object sender, DispatcherTimer e)
{
Seconds++;
MainTextBlock.Text = Seconds.ToString();
}
Anyway, I see this error and I cannot figure it out.
Any help in finding a better solution for my needs is welcome, too.
Please edit above DispatcherTimer_Tick like
the following. You could press + = Tab key to generate evet handle method automatically.
private void DispatcherTimer_Tick(object sender, object e)
{
}