Not able to reference Image source with relative path in xaml

后端 未结 3 1696
鱼传尺愫
鱼传尺愫 2020-12-15 17:04

I have created a ClassLibrary project, and added a xaml of Window type. I wrote a console application and showing this wpf window.

The problem is I have to show an I

3条回答
  •  执笔经年
    2020-12-15 17:31

    If Images folder is added in same project of its usage, this should work for you:

    
    

    Or use Pack Uri specifically:

    
    

    In case image resides in different project than current project where your XAML resides, you have to use more verbose definition of Pack URI where you have to specify the assembly name where image is added.

    
    

    Replace Assembly with actual assembly name where image is added into.


    Also make sure Build Action is set to Resource for file Folder-icon.png.


    UPDATE:

    More verbose definition of Pack URI works in sample as well. Try this out:

    
    

提交回复
热议问题