DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Microsoft Information Leaker 'Exiting the Game', But Not Without Spilling More Beans
  • HowTo: Store and Retrieve Images in a SQL CE Database on Windows Phone Mango
  • Using the TabControl on Windows Phone 7
  • Using the LongListSelector control on Windows Phone 7

Trending

  • How to Format Articles for DZone
  • Going Stateless: Scaling MCP Servers to Cloud-Native Java and HTTP
  • Docker Hardened Images Are Free Now — Here's What You Still Need to Build
  • The Twelve-Factor Agents: Building Production-Ready LLM Applications

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

By 
Senthil Kumar user avatar
Senthil Kumar
·
Nov. 07, 11 · News
Likes (0)
Comment
Save
Tweet
Share
11.8K Views

Join the DZone community and get the full member experience.

Join For Free

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

 

Windows Phone

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

Opinions expressed by DZone contributors are their own.

Related

  • Microsoft Information Leaker 'Exiting the Game', But Not Without Spilling More Beans
  • HowTo: Store and Retrieve Images in a SQL CE Database on Windows Phone Mango
  • Using the TabControl on Windows Phone 7
  • Using the LongListSelector control on Windows Phone 7

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook