How to Load Image that is set as Embedded Resource in BuildAction in Windows Phone ?

In one of my previous posts , i explained how to load the Image that is Set as Resource in Build Action .

In this blog post , i will provide you an sample that loads the image which is set as “Embedded Resource” in Windows Phone using the Assembly’s GetManifestResourceStream .

Use the GetManifestResourceStream method in the Assembly object by passing the image name .

How to Load Image that is set as Embedded Resource in BuildAction in Windows Phone ?

Make sure that the image is set to the Embedded Resource and when passing the image name pass the image name along with the Namespace as shown in the below sample code where PhoneApp3 is the ProjectName and StartScreen.jpg is the file name .

Set the BitMapImage’s source to the stream and assign this to the Source property of the Image .

private void button1_Click_1(object sender, RoutedEventArgs e)
{
Assembly CurrentAssembly;
CurrentAssembly = Assembly.GetExecutingAssembly();
Stream EmbeddedResourceStream = CurrentAssembly.GetManifestResourceStream
"PhoneApp3.StartScreen.jpg");
BitmapImage bitMapImage = new BitmapImage();
bitMapImage.SetSource(EmbeddedResourceStream);
image1.Source = bitMapImage;
}
How to Load Image that is set as Embedded Resource in BuildAction in Windows Phone ?
How to Load Image that is set as Embedded Resource in BuildAction in Windows Phone ?

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

In this post, you’ll learn about the Win32 Error “0x000019E5 – ERROR_COULD_NOT_RESIZE_LOG” that you get when debugging system erors in...
In this post, you’ll learn about the error “CO_E_DBERROR 0x8004E02B” that is returned when working with COM based APIs or...
In this post, you’ll learn about the Win32 Error “0x000019D0 – ERROR_LOG_BLOCK_VERSION” that you get when debugging system erors in...