Many tips are involved in Windows Phone 7 development. The following are three tips:
1. Set the application ProgramIcon
2. Boot screen in Windows Phone 7
3. Set the horizontal display of the application
1. Set the application icon
Right-click the solution of the WP7 application, select properties, and set the icon to the image you want, as shown in
Make sure that the image build method is content, for example. The final running effect is as follows:
2. Boot screen in Windows Phone 7
By default, the Windows Phone 7 Application uses the following default image as the startup screen of the program. You can set the startup screen in Windows Phone 7 as follows: 1. use your own image as the boot screen 2. start Screen with animation effect 3. do not use the startup Screen
For 1, we only need to replace splashscreenimage with our own image. For 3, if you do not want to use the startup screen, you only need to remove the splashscreenimage image from the project. The following describes how to enable an animation.
This is implemented using the backgroundworker class. The backgroundworker class is a class that opens up a background thread to process some operations and your UI can continue to respond to user operations. For more information about the backgroundworker class, You can Google its usage. In the rendering thread of WP7, if you want a user interface with continuous response, the backgroundworker class will become very useful. You can listen to the event of the process you want to perform and the signal of Operation completion. We use runworkerasync to enable background operations.
Note: we should not operate the user interface on the dowork of the backgroundworker class. You can perform operations related to the user interface in the progresschanged and runworkercompleted events. For more information, refer to the msdn tutorial
1. Create a WP7 project and add usercontrol)
2. Add the following namespace in mainpage. XAML. CS and edit the post Code As follows:
UsingSystem. Threading;
Using System. Windows. Controls. primitives;
Public Partial
Class Mainpage: phoneapplicationpage
{
Backgroundworker backroungworker;
Popup mypopup;
// Constructor
Public Mainpage ()
{
Initializecomponent ();
Mypopup =
New Popup () {isopen =
True , Child =
New Animatedsplashscreen ()};
Backroungworker =
New Backgroundworker ();
Runbackgroundworker ();
}
Private VoidRunbackgroundworker ()
{
Backroungworker. dowork + = (S, argS) =>
{
Thread. Sleep (5000 );
});
Backroungworker. runworkercompleted + = (S, argS) =>
{
This. Dispatcher. begininvoke () =>
{
This. Mypopup. isopen =False;
}
);
});
Backroungworker. runworkerasync ();
}
}
3. Edit the animatedsplashscreen. XAML foreground Code as follows:
<Stackpanel X: Name = "layoutroot" background = "black" Height = "800" width = "480">
<Textblock text = "windowsphonegeek sample splash screen" X: Name = "text" foreground = "green" fontsize = "65" textwrapping = "Wrap" margin = "0, 20, 0, 0 "/>
<Image Source = "logo.png" X: Name = "logoimage" stretch = "NONE" margin = "0, 0, 0
<Image. Projection>
<Planeprojection/>
</Image. Projection>
</Image>
<Toolkit: performanceprogressbar isindeterminate = "true" foreground = "green"/>
</Stackpanel>
And add the following animation resources.
<Usercontrol. Resources>
<Storyboard X: Key = "flippinganimation">
<Doubleanimationusingkeyframes storyboard. targetproperty = "(uielement. Projection). (planeprojection. rotationx)" storyboard. targetname = "logoimage">
<Easingdoublekeyframe keytime = "0" value = "0"/>
<Easingdoublekeyframe keytime = "" value = "1"/>
<Easingdoublekeyframe keytime = "" value = "360"/>
</Doubleanimationusingkeyframes>
<Objectanimationusingkeyframes storyboard. targetproperty = "foreground" storyboard. targetname = "text">
<Discreteobjectkeyframe keytime = "0">
<Discreteobjectkeyframe. value>
<Solidcolorbrush color = "white"/>
</Discreteobjectkeyframe. value>
</Discreteobjectkeyframe>
<Discreteobjectkeyframe keytime = "0: 0">
<Discreteobjectkeyframe. value>
<Solidcolorbrush color = "green"/>
</Discreteobjectkeyframe. value>
</Discreteobjectkeyframe>
</Objectanimationusingkeyframes>
</Storyboard>
</Usercontrol. Resources>
4. Edit the Post Code as follows:
Public Animatedsplashscreen ()
{
Initializecomponent ();
Storyboard flippinganimation =
This . Resources ["flippinganimation"]
As Storyboard;
Flippinganimation. Begin ();
}
3. Set the orientations of the application
Windows Phone 7 default orientations arePortraitOf
Switch to the horizontal bar as shown in Figure
We can make the following changes to set supportedorientations to portaitorlandscape, as shown in
Then run the program again. The effect is shown in figure