Windows 8 – Where do you start?

In Windows Phone seven, it was easy to find the starting page, you just looked in WMAppManifest.xml and look for the NavigationPage tag of the Tasks sections. The file is small and there isusually only one task.

Unfortunately in Windows 8, it is not as straight forward. Like WP7 apps, the real start is in Apps.xaml, but you have to look in the OnLaunched routine.

// Create a Frame to act navigation context and navigate to the first page
var rootFrame = new Frame();
rootFrame.Navigate(typeof(Views.MainPage));

// Place the frame in the current Window and ensure that it is active
Window.Current.Content = rootFrame;
Window.Current.Activate();

The first time I saw it, the typeof threw me. I was expecting a simple string containinf the name of the procedure.
In the Grid template it is even stranger. The invocation is buried in an if() statement and contains an extra argument that is passed to the routine.

if (!rootFrame.Navigate(typeof(GroupedItemsPage),"AllGroups"))
{
throw new Exception("Failed to create initial page");
}

After reading it, it makes sence, but for the first time, it does not stand out like the entry in WMAppManifest.xml in WP7 or the Main() at the end of the listing in classic C. Even leaving the starting routine names as MainPage would have been a help.

The journey continues…

John Marshall… Visio MVP Visio.MVPs.org

Published by johnvisiomvp

The original Visio MVP. I have worked with the Visio team since 1993