views:

226

answers:

2

I have a database that contains a table for storing URL Images (since storing the images as byte arrays could potentially slow the DB down massively). There are two fields in the image table, one that stores a URL to a low resolution image and one that stores a URL to a high Resolution image. So far this is just a concept and has not been fully implemented.

My question is, if i want to pull back these images via the database URL's to display in a Silverlight View, what is the best method of going about doing this and where on the web should I store the images? - On a personal web server?

Following this I want an awesome user experience for the image display. Potentially a thumbnail which when hovered over grows slightly and when clicks zooms to a bit lightbox display.

Help greatly appreciated.

A: 

One approach would be to add the images to your Silverlight application and then reference them using relative paths. Set the Build Action to "Resource" and Copy to Output Directory to "False". This will embed the image into your Silverlight application. Great for simplicity and performance, but not so great if you have large, plentiful, or constantly changing images.

<Image Source="Images/LoRes/10001.JPG" />

Another approach would be to deploy the images to the same web server that is hosting your XAP file. Using this approach, you can still reference the images by a relative path, only now the path is relative to the XAP, instead of the application root folder.

<Image Source="../Images/LoRes/10001.JPG" />

Silverlight also supports absolute URLs so you could deploy to a different web server entirely if you like.

<Image Source="http://myimages.com/Images/LoRes/10001.JPG" />

If the database only has image names, and you are doing data-binding, you can write a converter to take the image name and come up with the relative or absolute hyperlink.

The MSDN documentation for the Image class has more information.

Brad Tutterow
A: 

Quickest way that will allow you to retain any existing Images directories and organization, and keep them out of your XAP.

 string src = Application.Current.Host.Source.ToString();
 string applicationRoot = src.Substring(0, src.IndexOf("ClientBin"));
 //Where CLientBin is the location of your XAP file
 string imageURL = applicationRoot + "Images/MyImage.jpg"
PortageMonkey