Search code examples
uwpuwp-xamlxamarin.uwpuwp-navigation

Automatically navigate to a new page after a time in UWP


I'm trying to transition/navigate to a new page after a time (let's say 3 seconds), but nothing worked. I've tried this.Frame.Navigate(typeof(NewPage)); and it gives me an error "Object reference not set to an instance of an object.".

I've also tried

Thread.Sleep(3000); 
NewPage pg2 = new NewPage();
Window.Current.Content = pg2;

but it navigates immediately without waiting the 3 seconds.

The same problem I have also in am Xamarin app.


Solution

  • Thank you for your responses. In the mean time I've soled my problem and the code I'm using is the following:

    await Task.Delay(3000);
    
    Frame navigationFrame = Window.Current.Content as Frame;
    navigationFrame.Navigate(typeof(PageToNavigateTo));