Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

How to Specify the Startup Page in Windows Phone

DZone's Guide to

How to Specify the Startup Page in Windows Phone

· Mobile Zone
Free Resource

Launching an app doesn’t need to be daunting. Whether you’re just getting started or need a refresher on mobile app testing best practices, this guide is your resource! Brought to you in partnership with Perfecto

Introduction

Something that I get quite often is how do you specify the startup page in Windows Phone. Most people are trying to use the MVVM pattern and by default the MainPage.xaml lives in the root folder as shown below:

image

Most MVVM purist wants this folder to be clean, and only have the App.xaml and App.xaml.cs left. All of the Views should be located in the Views folder.

(You can move the LocalizedStrings.cs to a helper class)

How to do it?

I’ve found the easiest way to do is by deleting the MainPage.xaml file from the root of your project and adding it back to your Views (Add-New Item-Phone-Windows Phone Portrait Page). Then going to your WMAppManifest.xaml file found in Properties and changing the Navigation Page as shown below:

image

If you simply drag and drop the MainPage.xaml file, you will need to fix your x:Class in MainPage.xaml to point to the new location. So, in this case the project is named PhoneAppMVVM it would go from:

x:Class="PhoneAppMVVM.MainPage"

to

x:Class="PhoneAppMVVM.Views.MainPage"

and the MainPage.xaml.cs file would need to be modified from:

namespace PhoneAppMVVM

to

namespace PhoneAppMVVM.Views

Now we have a nicely structured MVVM application that is easy to find what you are looking for fast! The final project solution should look like the following:

image 

Wrap-up

I hope this helped and until next time, Michael signing off.

Keep up with the latest DevTest Jargon with the latest Mobile DevTest Dictionary. Brought to you in partnership with Perfecto.

Topics:

Published at DZone with permission of Michael Crump. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}