Computer Magic Logo
Load embedded image

Monday, May 2, 2016

Published by Aristotelis Pitaridis

We can embed images in our project and use these images in image controls. The following example demonstrates how to do it.

MyImage.Source = ImageSource.FromResource("App1.Windows.Images.pic.jpg");

Let's see what is the format of the parameter that we used in the FromResource method. App1.Windows is the name of the assembly. App1 is the name of the solution and this had as a result the windows project to have the assembly name "App1.Windows" which is the platform that I just used the previous code in order to load the picture.

We added the .Images because we placed the image inside the Images folder and the name of the picture is pic.jpg which is the last part of the parameter.