Setting a string as an image source in C #

Well, I was looking for several ways to fix this in my Windows Phone 7 application, but I can not find anything that works. What bothers me is that I did something similar, no problem, so I'm not sure why it doesn't work. The code calling me is this:
if (appSettings.Contains ("image")) myImage.Source = (string) appSettings ["image"]; still myImage.Source = "default.jpg";

The error I get is this

It is not possible to implicitly convert the type 'string' to 'System.Windows.Media.ImageSource.

The reason this bothers me is that I did this tutorial on Twitter , in which you directly bind the image source to a string. So what can I do to fix this?

+6
c # visual-studio-2010 windows-phone-7 silverlight
source share
2 answers

You need to specify ImageSource instead of a line when doing this from code:

Uri uri = new Uri("...", UriKind.Absolute); ImageSource imgSource = new BitmapImage(uri); myImage.Source = imgSource; 
+15
source share

If I did not find the correct part of Scott's post that you are looking at, it binds the image source to the URL.

Specificaly,

 ImageSource = tweet.Element("user").Element("profile_image_url").Value 

What would be like

http://a0.twimg.com/profile_images/1158022545/mickn_normal.jpeg

+2
source share

All Articles