views:

3668

answers:

1

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?

+1  A: 

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

Gordon Mackie JoanMiro
Thank you so much! And sorry for a duplicate question.
jkottnauer
hmmm, that link was more on WPF and not on silverlight...
VoodooChild
Just as applicable to Silverlight as far as this question goes.
Gordon Mackie JoanMiro