After I changed the line
timer.Tick += new EventHandler(timer_Tick); to timer.Tick += timer_Tick; it still gives an error which is
No overload for 'timer_Tick' matches delegate 'System.EventHandler'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 += timer_Tick;
timer.Interval = TimeSpan.FromSeconds(5);
timer.Start();
}
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
base.OnNavigatedFrom(e);
}
private void Btm_Click(object sender, RoutedEventArgs e)
{
App3.timer.Start();
}
private void timer_Tick(object sender, EventArgs e)
{
myCount++;
Label.Text = myCount.ToString();
}