Over a million developers have joined DZone.

How to change the StartPage of the Windows Phone 7 Application in Visual Studio 2010?

DZone's Guide to

How to change the StartPage of the Windows Phone 7 Application in Visual Studio 2010?

· Mobile Zone
Free Resource

Download this comprehensive Mobile Testing Reference Guide to help prioritize which mobile devices and OSs to test against, brought to you in partnership with Sauce Labs.

As a c# Windows Developer it was easier for me to change the startpage of the Application from the Program.cs file of the Windows Application project in Visual Studio . But how do i do thae same for the Windows Phone Application ??

There is no program.cs :( . Dont worry its easier to change it here too but in another xaml file .

Lets first rename the default MainPage.xaml to newstartpage.xaml  and try running the Application .

The Application will enter the RootFrame_NavigationFailed and Application_UnhandledException events and terminate .

Thats because , the Application somewhere references the MainPage.xaml which is not found .

You can see it in the local windows .

All that we need now is to change the startpage from MainPage.xaml to newstartpage.xaml .

  • Expand the Properties folder of the WP7 C# Project and Open the WMAppManifest.xml

  • This file keeps track of things that belongs to the Application .One of the Important Properties here is the tasks and the Defaulttasks .There are other properties or tags like The Capabilities section which tells the WP7 os about the capabilities of phone the application will use. Note the NavigationPage is still the MainPage.xaml .

  • Change the NavigationPage to newstartpage.xaml . verify the name of the file (casesensitive) when changing the NavigationPage which might result in an NavigationFailedException .
<DefaultTask Name="_default" NavigationPage="newstartpage.xaml" />
The xaml file should look like this
<?xml version="1.0" encoding="utf-8"?>
<Deployment xmlns="http://schemas.microsoft.com/windowsphone/2009/deployment" AppPlatformVersion="7.0">
<App xmlns="" ProductID="{8198fbcf-ddc8-428f-92c3-0b67e079ec6f}" Title="test" RuntimeType="Silverlight" Version="" Genre="apps.normal" Author="WindowsPhoneApplication4 author" Description="Sample description" Publisher="WindowsPhoneApplication4">
<IconPath IsRelative="true" IsResource="false">test.png</IconPath>
<Capability Name="ID_CAP_GAMERSERVICES" />
<Capability Name="ID_CAP_IDENTITY_DEVICE" />
<Capability Name="ID_CAP_IDENTITY_USER" />
<Capability Name="ID_CAP_LOCATION" />
<Capability Name="ID_CAP_MEDIALIB" />
<Capability Name="ID_CAP_MICROPHONE" />
<Capability Name="ID_CAP_NETWORKING" />
<Capability Name="ID_CAP_PHONEDIALER" />
<Capability Name="ID_CAP_PUSH_NOTIFICATION" />
<Capability Name="ID_CAP_SENSORS" />
<DefaultTask Name="_default" NavigationPage="newstartpage.xaml" />
<PrimaryToken TokenID="WindowsPhoneApplication4Token" TaskName="_default">
<BackgroundImageURI IsRelative="true" IsResource="false">Background.png</BackgroundImageURI>
  • Run the Application , you should see the Application in the Emulator now :)

Analysts agree that a mix of emulators/simulators and real devices are necessary to optimize your mobile app testing - learn more in this white paper, brought to you in partnership with Sauce Labs.


Opinions expressed by DZone contributors are their own.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}