Exploring the problem that the Image of the Image control of WPF cannot be displayed,

Source: Internet
Author: User

Exploring the problem that the Image of the Image control of WPF cannot be displayed,

In the wpf project, Image is used to display resource images, which can be displayed on the Interface but cannot be displayed during running.

<Image Source = "/Reform. STBHQ. common; component/Images/huaiy_0.png "Height =" 80 "HorizontalAlignment =" Left "Margin =" 80, 0, 0, 0 "Cursor =" Hand "cm: Message. attach = "[MouseLeftButtonUp] = [RestoreDB_Click ()]"> </Image>

After checking the image Resource file, it is found that the image generation method in the root directory is incorrect. Right-click the Image property and choose "generate" as the content instead of "Resource ".

Therefore, you need to change the generate operation to Resource.

The generate operation is set to Resource. The Resource will be added to the Assembly when it is generated. You can try to delete the original image. The image is displayed normally. Replace the original image with the new one, and the original image is still displayed. Images can be updated only when you select "regenerate.

The generated operation is set to content and will not be added to the Assembly. resources can be accessed only when resources are placed in the program running directory. The Debug directory is used for program running directory debugging, and the installation directory is used after installation. Unlike directly Placing resources in the program running directory, adding a Content resource file will add a custom feature to the AssemblyAssociatedContentFile to check whether the Assembly record file exists and its relative location.

 

 

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.