johnvisiomvp

Life with Visio and other Microsoft Toys!

Windows 8 – Where do you start?

leave a comment »

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

Advertisements

Written by johnvisiomvp

June 17, 2012 at 7:17 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: