Set Silverlight Startup Page
8/6/2010 3:47:11 PM
In sandboxing Windows Phone 7 recently I came across the need to change my startup page. The reasoning for this is simple: I have a core of the work completed and I want to sandbox a data call before I implement in the actual application. With conventional web projects this is as easy as right-clicking the file you want to and click 'Set As Start Page'. With the Windows Phone 7 SDK this luxury does not exist.
There is however a way to accomplish this with a little bit of code. Simply open up your projects App.xaml.cs and implement an Application_Startup method.
private void Application_Startup(object sender, StartupEventArgs e)
{
RootVisual = new SandboxPage();
}
SandboxPage is the name of my XAML page in this example. Here we simply set the RootVisual to an instance of our new page.
The second piece to this is registering this startup method in the App constructor a la:
public App()
{
Startup += Application_Startup;
}
This doesn't necessarily apply to Windows Phone 7. General Silverlight.
Easy.
C#,
Silverlight,
Windows Phone
