Binding Image Source to web address is not problem, it will work well... until you don't care about performance. The problem will appear if you want to cache images. Isolated storage is the only way to store downloaded files in Silverlight, no matter Browser or Windows Phone. It is not so difficult to download image file from the Internet and save to Isolated Storage, but how to use it in Silverlight Page?
Well, let's try to figure it out. First define the image converter:
public class IsoImageConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter,
System.Globalization.CultureInfo culture)
{
var bitmap = new BitmapImage();
try
{
var path = (string)value;
if (!String.IsNullOrEmpty(path))
{
using (var file = LoadFile(path))
{
bitmap.SetSource(file);
}
}
}
catch
{
}
return bitmap;
}
private Stream LoadFile(string file)
{
using (var isoStore = IsolatedStorageFile.GetUserStoreForApplication())
{
return isoStore.OpenFile(file, FileMode.Open, FileAccess.Read);
}
}
public object ConvertBack(object value, Type targetType, object parameter,
System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
Next, define the link in App.xaml for use in XAML code:
<textarea style="display:none;"
class="originalCode"><local:IsoImageConverter x:Key="IsoImageCoverter"/>
</textarea>
And finally bind to string
path to Isolated Storage image file:
Image Source="{Binding ImagePath, Converter=
{StaticResource IsoImageCoverter}}"/>