How do I format a Uri when binding an Image in Silverlight?
- by Scott
I haven't been able to find an answer to this.
I have a database that has image paths in it ("images/myimage.jpg").  These images exist on my asp.net site which is also where I host the SL.  I want to bind these images to my ListBox control so that the image displays.
I have read that since I have a string value, "images/myimage.jpg", that I need to convert it to a BitMap image.  I have done this:
the xaml:
 <Image Source="{Binding ImageFile, Converter={StaticResource ImageConverter}}"/>
the ImageConverter class:
    public object Convert(object value, Type targetType,
                                  object parameter, CultureInfo culture)
            {
                try
                {
                    Uri source= new Uri(value.ToString());
                    return new BitmapImage(source);
                }
                catch(Exception ex)
                {
                    return new BitmapImage();
                }
            }
I get an error when creating the Uri, "The Format of the URI could not be determined".  What am I doing wrong?  If I create a Uri that looks like this: http://localhost:49723/images/myimage.jpg, it works just fine.
Why doesn't just "images/myimage.jpg" work?