On the first day of Windows Phone 7, design the startup page and application icons.

Source: Internet
Author: User

Every Windows Phone 7 Application may take some time to start. During this waiting period, some startup screens are often displayed to refresh the scenes first, in this case, the user is impatient because the loading time is too long. In this startup screen, it is a good publicity page, which can put the product advertisement, the author introduces that the display and brand information are displayed on this page. Of course, the time cannot be too long or too short. Otherwise, if the screen starts to run too fast, then there is no need to appear, and sometimes the necessary "slow" is also an art.

First, create a default Silverlight for Windows Phone project.

 

We just want to create a QR code generator application, using the mango application Windows Phone OS 7.1.

Add a Windows Phone portrait page and name it splashscreen. in XAML, right-click the project, select Add → new item → Windows Phone portait page, delete all interface elements in the page, and add an image control to splashscreen. XAML page.

Because the screen size of Windows Phone 7 is currently fixed to 480 (width) x 800 (height), and we want thisStartup ScreenThe image can occupy the entire screen, so we must adjust the attributes of the image control. This is not accurate by dragging the image, and it will be faster to directly modify the attributes.

Then prepare a 480x800 image (Note:: Images in GIF format cannot be used. Here, my image file name is splashscreen.png and put it in an images directory.

Then adjust the attributes of the image control and set the source attribute to the image. We can also copyBuild action Project PropertiesSlaveEmbedded ResourceAdjustedContentTo reduce the size of the WP7 component and accelerate the loading of the entire application. However, after modifying the project properties of the file, the source attribute of your image control must also be adjustedRelative to the project root directoryOfAbsolute pathIt is difficult to use text descriptions. See the figure below:

There are two possible purposes for starting a screen:

  1. Because the initialization time of the application is too long, a simple wait page needs to be displayed first. This is also one of the requirements for Windows Phone application certification requirements (see5.2.1 launch timeThis rule.Startup ScreenOne of the important reasons.
  2. The execution of the program is too fast, and the user does not feel it, but it must be elegant and calm to be slow.

Mainpage. before the official execution of XAML, we hope to jump to the splashscreen first. when a XAML page is displayed, we use a popup window to block the mainpage. the XAML page, and the pop-up window is wrapped with splashscreen. the following code is used to describe the XAML page:

Private backgroundworker backroungworker;
Private popup mypopup;

// Constructor
Public mainpage ()
{
Initializecomponent ();
Mypopup = new popup () {isopen = true, child = new splashscreen ()};

Backroungworker = new backgroundworker ();
Runbackgroundworker ();

}

Private void runbackgroundworker ()
{
Backroungworker. dowork + = (S, argS) =>
{
Thread. Sleep (3000 );
});

Backroungworker. runworkercompleted + = (S, argS) =>
{
This. Dispatcher. begininvoke () =>
{
This. mypopup. isopen = false;
});
});

Backroungworker. runworkerasync ();
}

Let's display the startup screen for 3 seconds and then turn it off automatically. F5 to see the effect.

The startup page is ready, and the next task is to set the application icon.

Wmappmanifest. the XML file also defines icons, background images, and application titles. You can use PNG bitmap files as icons. The default icon file is applicationicon.png, and the background image is backgroud.png, you can edit the XML code or modify these attributes on the "application" tab of the project properties.

Today I learned how sometimes the GUI interface is not as convenient as it is sometimes easier to manually modify the XAML or adjust the attribute value than to drag it using the graphic interface. WP7 does not support GIF images (this is a patented image format). You should avoid using GIF images when using them. Otherwise, you will still think that the image is a WP7 bug. You can also adjust the build Action Project attribute of the splashscreen.png image file from embedded resource to content, which can reduce the size of the WP7 component (assembly) and accelerate the loading of the entire application. I learned how to correctly use popup to displayStartup ScreenAnd the backgroundworker's background job is used to set a fixed time for automatic shutdown.Startup Screen. Finally, I learned how to set application icons and background images.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.