locked
Windows Phone Navigate between pages in time RRS feed

  • Question

  • Hi everybody. I m developing a game for windows phone. I need to navigate between pages by time. For example, when user open page1, after 30 sec it will navigate to page2 automatically. Is it possible ? thx for helps.
    Wednesday, November 26, 2014 3:19 PM

Answers

  • Add a DispatcherTimer and set 30 second as interval. Start the DispatcherTimer in Load event and on tick event stop the DispatcherTimer and navigate to page2.

    http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.dispatchertimer

    DispatcherTimer dispatcherTimer = null;
    private void pageRoot_Loaded(object sender, RoutedEventArgs e) 
    {
    	dispatcherTimer = new DispatcherTimer();
            dispatcherTimer.Tick += dispatcherTimer_Tick;
            dispatcherTimer.Interval = new TimeSpan(0, 0, 30);
            dispatcherTimer.Start();
    }
    
    private void dispatcherTimer_Tick(object sender, EventArgs e)
    {
         dispatcherTimer.Stop();
         NavigationService.Navigate("Page2.xaml");
    }


    Gaurav Khanna | Microsoft VB.NET MVP | Microsoft Community Contributor


    Wednesday, November 26, 2014 4:21 PM