Image source using project resource (WPF)

寵の児 提交于 2019-12-05 15:36:12

First, mark you image file as a "Resource" in the properties window of Visual Studio. Then you can quite easily reference the resource using the file name:

<Image x:Name="image1" Source="theimage.png" />

If you have put your image in a folder, you can use

<Image x:Name="image1" Source="/folder/theimage.png" />

You wanted to reference your image in XAML right?

like this

<Image Source="Resources\MyImage.png" />

and you dont need to add the image to the project resource. just add the images to your project via solution explorer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!