Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

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

DZone's Guide to

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

· Mobile Zone
Free Resource

Discover how to focus on operators for Reactive Programming and how they are essential to react to data in your application.  Brought to you in partnership with Wakanda

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 a 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.

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;
}

 

Learn how divergent branches can appear in your repository and how to better understand why they are called “branches".  Brought to you in partnership with Wakanda

Topics:

Published at DZone with permission of Senthil Kumar, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}