The default page for Windows Phone 7 is configured in the wmappmanifest. xml file.
<Tasks>
<Defaulttask name = "_ default" navigationpage = "loginpage. XAML"/>
</Tasks>
If the initial Page is changed according to the status when the program is started, for example, when the program is started, it determines whether the user is logged on. If the program is not logged on, it will jump to loginpage. XAML; otherwise, it will jump to other interfaces.
The Code is as follows:
Private void initializephoneapplication ()
{
If (phoneapplicationinitialized)
{
Return;
}
// Create the frame but don't set it as rootvisual yet; this allows the splash
// Screen to remain active until the application is ready to render.
Rootframe = new phoneapplicationframe ();
Rootvisual = rootframe;
Rootframe. navigated + = completeinitializephoneapplication;
// Handle navigation failures
Rootframe. navigationfailed + = rootframe_navigationfailed;
Rootframe. Navigating + = new navigatingcanceleventhandler (rootframe_navigating); // Add the navigating event
// Ensure we don't initialize again
Phoneapplicationinitialized = true;
}
Void rootframe_navigating (Object sender, navigatingcanceleventargs E)
{
If (E. Uri. tostring (). Contains ("loginpage. XAML ")&&! Api. isverify) // The conditions must be met here, because rootframe uses navigating when navigate on any page, or uses the same recursive method as rootframe. navigated.
{
E. Cancel = true; // cancel the event
String uristring = "/loginpage. XAML ";
Uri ur = new uri (uristring, urikind. Relative );
This. rootframe. Dispatcher. begininvoke (delegate
{
This. rootframe. navigate (UR );
});
}
}