Sep 3 2011

Displaying an Image from Isolated Storage

Category: MobileJoel Ivory Johnson @ 04:51

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;
        if (String.IsNullOrEmpty(path))
            return null;
            using (var sourceFile = ISF.OpenFile(path.Substring(9), FileMode.Open, FileAccess.Read))
                BitmapImage bm = new BitmapImage();
                return bm;
            BitmapImage bm = new BitmapImage(new Uri(path));
            return bm;

    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.

Tags: ,

May 3 2010

Silverlight Themes Available

Category: Desktop and ServerJoel Ivory Johnson @ 12:03

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.


Apr 1 2010

Compatibility with WP7S and Silverlight 3 for the Desktop

Category: MobileJoel Ivory Johnson @ 01:34

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)

Tags: ,

Mar 15 2010

Free Upgrade to Expressions Blend 4

Category: Desktop and Server | MobileJoel Ivory Johnson @ 05:21
If you have Expressions Blend 3 you are in luck. Microsoft will be allowing you to upgrade to Expressions Blend 4 for free.

Tags: , ,

Mar 7 2010

Silverlight base Applications on Windows Phones a Good Thing

Category: MobileJoel Ivory Johnson @ 05:54

Some one at 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!

Tags: ,