Kristifor Milchev
Kristifor Milchev

Reputation: 21

Page navigation event

I was reading trough the documentation for UWP and I got stuck a little.

I have few pages that connect to WCF service taking some information of it few of them download pictures and take few seconds to load.

So I've decided to implement a loading screen while they load however when I try using

this.Frame.Navigate(typeof(page)); 

I get stuck in a deadlock state everything freezes while the new page is loading I've tried putting on pageloading event on the other page but this is not helping much since its still locked on the last form.

Does anyone know the right event that I need to call when calling this.Frame.Navigate() so I can initialize my loading control while the new frame is loaded?

Upvotes: 0

Views: 2939

Answers (2)

Vijay Nirmal
Vijay Nirmal

Reputation: 5837

  1. Navigate to Loading Screen

    this.Frame.Navigate(typeof(LoadingScreen));
    
  2. In OnNavigatedTo event in LoadingScreen "download pictures"

    protected override async void OnNavigatedTo(NavigationEventArgs e)
    {
        await DownloadPictures();
        //After downloading, navigate to the next page
        this.Frame.Navigate(typeof(page)); 
    }
    

Upvotes: 1

Xeorge Xeorge
Xeorge Xeorge

Reputation: 462

try launching the view on a separate window like this

       try
        {
            CoreApplicationView Nv= CoreApplication.CreateNewView();
            var z = CoreApplication.MainView;

            int id= 0;
            await 
    Nv.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
            {
                Frame frame = new Frame();
                frame.Navigate(typeof(page));

                Window.Current.Content = frame;
                // You have to activate the window in order to show it later.
                Window.Current.Activate();




                id= ApplicationView.GetForCurrentView().Id;
            });
            bool viewShown = await ApplicationViewSwitcher.TryShowAsStandaloneAsync(id);


        }
        catch (Exception eee)
        {
            Windows.UI.Popups.MessageDialog errorBox =
               new Windows.UI.Popups.MessageDialog("Couldn't Create New 
          Window: " + eee.Message);
            await errorBox.ShowAsync();


        }

Upvotes: 0

Related Questions