Project Resource Source (WPF)

I added a bunch of images as project resources. Now I want to use them in my WPF application using an image control. How to assign a resource to an image control source?

+4
source share
2 answers

First mark the image file as โ€œResourceโ€ in the Visual Studio Properties window. Then you can easily reference the resource using the file name:

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

If you placed your image in a folder, you can use

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

Would you like to reference your image in XAML correctly?

like this

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

and you donโ€™t need to add an image to the project resource. just add images to your project through explorer

+2
source

Source: https://habr.com/ru/post/1303219/


All Articles