jkottnauer
jkottnauer

Reputation: 413

Binding images to Image in Silverlight 2

I'm building a Silverlight 2 application and I need to bind some images to Image object declarated in XAML. I'm doing some other binding in the application and it works just fine, I'm having problem with only images!

This is it's XAML:

<Image Source="{Binding Path=ThumbNail}" Style="{StaticResource ThumbNailPreview}" />

And this is the C# code-behind:

ThumbNail = (string)story.Element("thumbnail").Attribute("src")

I'm just parsing the URL's from a XAML file. When I try to do a foreach loop over all of the ThumbNail properties, it returns the URL as expected. As I said, all other binding works great, so it has to be a problem between the Image control and the ThumbNail property. I also tried chanding the datatype from string to Uri, but nothing happened. Could anyone help me?

Upvotes: 2

Views: 9100

Answers (1)

Gordon Mackie JoanMiro
Gordon Mackie JoanMiro

Reputation: 3489

I think this has already been asked and answered in StackOverflow here

The key is that the ImageSource property is not a string but a System.Windows.Media.Imaging.BitmapImage type and so needs to be converted.

HTH

Upvotes: 4

Related Questions