How to specify path to Image resources in WPF application

后端 未结 2 1608
遇见更好的自我
遇见更好的自我 2021-01-26 07:55

Below is in a flow document
I can see all 5 in design
When I run the program then none are found
How can I get relative path to work?



        
相关标签:
2条回答
  • 2021-01-26 08:42

    Currently the image files are part of the solution, but not part of the project, so they're not embedded in the assembly when you compile. You need to add the to the Gabe2a project, with the build action set to "Resource".

    0 讨论(0)
  • 2021-01-26 08:43

    1). You have to add all Image files to your WPF project, for example, place them in Img directory; by default Build Action will be set to 'Resources'. Keep it intact.

    2). Specify path to the image like:

    Source="/[assembly name];component/Img/ImageFile
    

    Pertinent to your particular case, the following syntax looks OK:

    Source="/Gabe2a;component/Images/VennUnion.png"
    

    Hope this will help. Best regards,

    0 讨论(0)
提交回复
热议问题