Dynamically show image in Silverlight

I had a requirement to show images in Silverlight dynamically and that was quite simple can be done in two steps in a minute but I spend nearly hours to figure out the issue.

Dynamically show images from code behind

var bitmapImage = new BitmapImage(new Uri(“http://www.google.co.in/intl/en_com/images/logo_plain.png”);
image1.Source = bitmapImage;

The above code will make you smile only if you run the application from the silverlight web application project and not the default genarated testpage.html

The whole point is that this scenario works only if the application is hosted or run from an local web application with fileserver.

Note: Only JPG,PNG,BMP works this way and GIF doesn’t go well. Check this post to make GIF work

http://www.eggheadcafe.com/tutorials/aspnet/c0046ba1-5df5-486a-8145-6b76a40ea43d/silverlight-handling-cro.aspx

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Powered by WordPress.com.

Up ↑

%d bloggers like this: