How to use Image Component in WPF


Hi. Today I will show how to add some image to your application and show it in the Image component.

Simply create new project, and add folder to it named Images. Then add existing image to this folder.

Make sure that this image has Build Action set to “Resource”:

image

Then add XAML with Image control and specify image location with the following syntax:

<Grid> <Image Source="/EmbededResourcesSample;component/Images/1.jpg"/> </Grid>

As you can see, first part of URL is a name of the assembly that contains image and second part is relative path to the image you want to use.

If you run application you will get the following window:

image

From now you should be able to use your own static images in your application. Bye 😉

Advertisements