I was writing some code for someone and for the scenario I needed to display images that were stored in isolated storage. Unfortunately at present the Image element in Silverlight doesn't support displaying images from Isolated storage. You must load the image yourself and then give the loaded image to an Image element. At first glance this is annoying because I wanted to just give the image a URI to something stored in solated storage and let the element do it's magic. After a few minutes of thinking I realized I can still do this provided I create a converter to do some of the needed work. I wanted to ensure the converter was both compatible with the URIs that point to isolated storage and those that refer to locations on the internet.
public class FilePathToImageConverter: IValueConverter
private static IsolatedStorageFile ISF = IsolatedStorageFile.GetUserStoreForApplication();
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
string path = value as string;
using (var sourceFile = ISF.OpenFile(path.Substring(9), FileMode.Open, FileAccess.Read))
BitmapImage bm = new BitmapImage();
BitmapImage bm = new BitmapImage(new Uri(path));
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
throw new NotImplementedException();
To use it bind a string value to the Source property of the Image element. The file path must be prefixed with "isostore:" for the converter to extract the image from isoated storage. if the "isostore:" prefix is not present the converter will attempt to load the image using a regular Uri.
I've been waiting for this for a while but now the Silverlight 4 themes are now available for download. If you've not seen them before they are some pretty cool looking clean themes that you can use in your XAML applications. If you are looking for the Metro look go for the theme called Cosmopolitan.
You can grab them from here.
Not long ago I was trying to port an application from Silverlight 3 to the Silverlight variant used in Windows Phone 7 Series. I thought I had run into an obstacle when I realized that a piece of functionality that I was using was actually implemented by a third party and there wasn't a WP7S version. So I decided to try to use the library anyway and it worked! Earlier this week I cam across a message in a post in the MSDN forums by Shawn Oster that states some of the requirements for sharing code between Silverlight 3 and WP7S.
- The Class Library must be based off of Silverlight 3, not 4
- Don't reference Windows Phone specific controls in the library
- Don't reference System.Windows.Browsers (it's desktop specific)
- Don't use IQueryable (it's not in WP7S)
Some one at MSMobiles.com gave me the top Silverlight on Windows Phone 7 Series is Good and asked me to write something to fit that topic. So I did, and now it is published. If you are interested go read it.. And remember whether you agree or disagree make your views known in the forums!