(8) teach you how to write a weather forecast program: Customize the about message box and program ending

Source: Internet
Author: User

The program is completed here. First, we should have a dialog box such as about. Displays information about programs. It's not as ugly as MessageBox...

For example:

 


Then, add an IconButton on the MainPage and ApplicationBar. Used as a pop-up window. The icon is dark \ appbar.questionmark.rest.png under the SDK directory. Copy the icon to the Icons directory and change the generated operation to the content. Add a click event. The Code is as follows:

<Shell: ApplicationBarIconButton IconUri = "/Icons/appbar.questionmark.rest.png" Text = "about" Click = "ApplicationBarIconButton_Click_1"/>

 

So how can we create a pop-up window. All those who have learned silverlight know that the elements below can overwrite them. Therefore, we can use the canvas layout to make the canvas background color different from the original background color, so we can see the effect similar to the pop-up window.

Another is the use of plug-ins, can make good-looking pop-up window, such as coding4Fun, specific can see I write this: http://blog.csdn.net/fengyun1989/article/details/7384733

We only need to add the following code under the original Textblock and other elements:

 

 

<! -- About pop-up window: uses the canvas layout and the visibility attribute to pop up the window --> <canvas X: Name = "infomsg" grid. columnspan = "2" grid. rowspan = "3" grid. column = "0" grid. row = "0" background = "lightgray" visibility = "Collapsed"> <button X: Name = "cancel" width = "70" Height = "70" canvas. top = "-12" canvas. left = "392" Click = "cancel_click" content = "X" background = "black" foreground = "white"/> <textbox X: name = "about" textwrapping = "Wrap" canvas. left = "30" canvas. top = "80" width = "400" Height = "300" isreadonly = "true"/> </canvas>

 


Add location:

 

Then, add the click event processing in the cancel button of the iconbutton and about pop-up windows of the ApplicationBar:

 

# Click Event private void applicationbariconbutton_click_1 (Object sender, eventargs e) {If (infomsg. visibility = visibility. collapsed) {infomsg. visibility = visibility. visible;} else infomsg. visibility = visibility. collapsed;} private void cancel_click (Object sender, routedeventargs e) {infomsg. visibility = visibility. collapsed;} # endregion

Add such a line to the loaded event of mainpage and assign the value to the textbox in the pop-up window of about:

 

About. Text = "this program is designed by fengyun1989 and is only for reference exercises. If questions and suggestions are asked, mail them to the 1024919409@qq.com ";

 


Next, modify the title of the two pages and modify the Title 8 of the forecasttemplate.

Next, modify the program icon. Open Properties \ wmappmanifest. XML in Solution Explorer. There are some program descriptions, startup screens, icons, and other settings. Only a few simple English words can be understood by ordinary people.

 

There is also the startup screen. Splashscreenimage.jpg. The specification is 480*800.

I modified it slightly. The Modification result is as follows:

 

 

Now, the "hands-on weather forecasting program" is over. In fact, writing such a program is like building blocks. It depends on how you build a high-rise building. Many knowledge points in the program can be made into many things. For example, a ordering program for android was seen a few dialog boxes and two listboxes a few days ago. After the order is selected, a pop-up window will display the phone number of the person who sent the message to the food delivery. If WP7 is used, it is quite easy to use two Listpicker + one Task that sends a text message.

Therefore, writing a decent program is not very difficult...

Download the final project: WebForecast

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.