Thursday, 30 July 2015

Page.Loaded Fails to Fire

Yesterday, we installed windows 10.

We tried out our app BouncingBalls and was surprised that the balls didn’t start bouncing, when they did on Windows 8.1

Even more oddly, if you opened the settings page, they would suddenly start bouncing.

Firing up the debugger, we found that Page.Loaded was not firing when we navigated to the main page.  The code we use is similar across all of our apps, but for some reason this particular app was not behaving.

After quite a bit of code hacking, we found it came down to the handling of the splash screen.

We add a handler for Splashscreen.Dismissed, and handle navigation to the main page (or another page depending on trial mode) from there.

In our OnLaunched handler, we called

Window.Current.Content = _launchframe;

but we hadn’t yet navigated to a page, or set any content for our frame _launchframe.

In the Dismissed handler, we did this:

var nowarn = _launchFrame.Dispatcher.RunAsync( CoreDispatcherPriority.Normal, () => ContinueAfterSplash1());

And in ContinueAfterSplash1() we eventually call after a few async calls.

_launchFrame.Navigate(typeof(BouncingBalls.MainPage), args)

MainPage received an OnNavigatedTo call, but never received the Loaded event we wired up.

The solution?

In the end, we changed the code not to call Window.Current.Content until after we successfully navigated to the MainPage.

For whatever reason, that caused the Loaded event to fire every time.

How to install VS2015 Community

If you have more than one machine, you may not want to wait for every package to download over and over again.  Here’s how you can get an image on your PC

First head on over to

Click on Download Community Free, which will save a file onto your PC named vs_community.exe

Then open a command prompt and run the program with the /Layout argument.

That will download everything onto your PC.

Did you do this before the SDK was released?

I tried installing the standalone SDK, but unfortunately, that didn’t update VS2015 to include the Windows 10 portions.

However, I found that you could get the SDK by running the /Layout argument again and extracting to the same location.  If you then run the setup again, you’ll get the the options for installing the universal tools and the SDK.

I did this after I uninstalled VS2015 though.  You may not need to do that step.

After the download completes

Now just run the vs-community exe again and choose your installation options.