Windows phone7 blog: Add application bar-http://blog.csdn.net/toddhan/article/deta in Windows Phone

Source: Internet
Author: User
Tags email account

In Windows Phone, how does one add ApplicationBar? This point has been clearly stated in APP hub:

Http://create.msdn.com/en-US/education/quickstarts/Navigation

In fact, each time you create a windowsphone project, the Definition Format of ApplicationBar has been written in the default XAML, but this part is commented out. What we need to do is to open the comment (remove <! -->). This is really convenient. Go back to the design page and see the following four circles!

This is the desired iconbutton, but normal buttons have images, such as "playing", which is generally a triangle, and "stop" is usually a box. If you run the project now, what you see is a cross! It doesn't matter. Just add the desired icon!

However, the msdn example has a key point: how to add the iconbutton icon? How are image attributes set ?? In the routine, The XAML file is defined as follows:

<Phone: phoneapplicationpage. applicationBar> <shell: ApplicationBar isvisible = "true" ismenuenabled = "true"> <shell: applicationbariconbutton X: name = "newbutton" iconuri = "/images/appbar.new.rest.png" text = "new" Click = "newbutton_click"/> <shell: applicationbariconbutton X: name = "folderbutton" iconuri = "/images/appbar.folder.rest.png" text = "Folders" Click = "folderbutton_click"/> <shell: applicationbariconbutton X: name = "syncbutton" iconuri = "/images/appbar.refresh.rest.png" text = "sync" Click = "syncbutton_click"/> <shell: ApplicationBar. menuitems> <shell: applicationbarmenuitem text = "Settings"/> <shell: applicationbarmenuitem text = "Add email account"/> </shell: ApplicationBar. menuitems> </shell: ApplicationBar> </Phone: phoneapplicationpage. applicationBar>

 

We can see that iconuri = "/images/appbar.new.rest.png" indicates that a connection is added to the image and the image path is in/images! Go back and check out your Solution Explorer. There is definitely no such directory under the project, right? Therefore, you must create one by yourself: Right-click the project name, add, folder, and name it images. Where can I find the image in it? In the msdn example, there are many requirements on the image format... Do not draw it by yourself. Use the system's built-in icons: C: \ Program Files \ microsoft sdks \ Windows Phone \ v7.0 \ icons \ Dark with black themes, find the desired image, right-click images in solution, and add it! Is this the end? Of course not! The following is what is not mentioned in the example:

After adding the image, the default action build for these images is "resource" and must be changed to "content "!! Then change copy to output directory to "copy If newer "!! (Select all the icon images, right-click the image, and you can see the two options in it !)

I did not consider the image attribute settings. Even if the path is added to the XAML, the initialization is hard-coded in C #. At runtime, the button icon is still an indifferent "Cross "!

This is found here: http://msdn.microsoft.com/en-us/library/ff431806 (V = vs.92). aspx

 

To add icon button images to your Windows Phone application, detailed steps are as follows:
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.