I am not sure what is wrong with my code can someone help fix the error? The error is in the timer.Tick()
line. It's supposed to make a stopwatch.
namespace App3
{
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
}
private int myCount;
protected override void OnNavigatedTo(NavigationEventArgs e)
{
DispatcherTimer timer = new DispatcherTimer();
timer.Tick += new EventHandler<object>(timer_Tick);
timer.Interval = TimeSpan.FromSeconds(5);
timer.Start();
}
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
base.OnNavigatedFrom(e);
}
private void timer_Tick(object sender, EventArgs e)
{
myCount++;
Label.Text = myCount.ToString();
}
}