WP image loading format/generating attribute content and resource

Source: Internet
Author: User
Pay attention to the loading mode when developing WP. In WP7, resource files mainly have three buildaction attributes: Resource/content/none. By default, resource loading is selected.

When I first started learning WP development, I encountered a problem that most people would encounter: Why cannot images be displayed when the image is set to resource, you can set it to the content format.
(1) The three generation attributes of the resource file are briefly described as the differences between the three loading methods. Resource Method: when a program is packaged, the resource file is integrated into the xap file DLL. Content Method: resource files and DLL files are packaged into xap files independently. Sample, which exists in the compressed package as an actual image file. None method: The resource file is neither directly packaged in the xap file nor embedded in the xap DLL. during compilation, the resource file is completely ignored.
(2) set the URI of the image. Generally, when the resource file is integrated into the DLL, the start time of the program will include the time required to load the resource file, however, once these files are loaded, they can be quickly accessed during the program running. When a resource file exists in an independent form, the program will wait until the resource is loaded in real time. Therefore, when the program needs to be quickly started, you can set the resource file of the sample slice to the content generation attribute. Otherwise, you can set it to the resource attribute. The previously encountered image cannot be displayed because it is set to the resource attribute. One reason may be that the URI settings are incorrect. Resource and content have their own URI settings. For example, resource: <Image Source = ".. \ imagesasresource \ bg1.png"/>
Or <appnamespace; component/imagesascontent/bg1.png> content: <Image Source = "/imagesascontent/bg1.png"/>
Deepen understanding in this aspect. If you can flexibly load resource files, you can optimize the memory usage.

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.