Displaying the Saved Pictures in the Windows Phone 8 emulator

Posted by Laurent Bugnion on Geeks with Blogs See other posts from Geeks with Blogs or by Laurent Bugnion
Published on Sun, 18 Nov 2012 14:50:48 GMT Indexed on 2012/11/18 17:02 UTC
Read the original article Hit count: 368

Filed under:

One cool feature of the Windows Phone emulator is that it allows you to select pictures from your app (using the PhotoChooserTask) without having to try your app on a physical device. For example, this code (which I used in some of my recent presentations) will trigger the Photo Chooser UI to be displayed on the emulator too:

private Action<IEnumerable<IImageFileInfo>> _callback;
        
public void SelectFiles(Action<IEnumerable<IImageFileInfo>> callback)
{
    var task = new PhotoChooserTask
    {
        ShowCamera = true
    };

    task.Completed += TaskCompleted;
            
    _callback = callback;
    task.Show();
}

void TaskCompleted(object sender, PhotoResult e)
{
    if (e.Error == null
        && e.ChosenPhoto != null
        && _callback != null)
    {
        var fileName = e.OriginalFileName
            .Substring(e.OriginalFileName.LastIndexOf("\\") + 1);

        var info = new FileViewModel(e.ChosenPhoto, fileName);
        var infos = new List<IImageFileInfo>
        {
            info
        };

        _callback(infos);
    }
}

In Windows Phone 8 however, when you execute this code, you will be shown an almost empty Photo Chooser UI:

Missing Saved Pictures

Notice that the “Saved Pictures” album is missing. At first I thought it was just not there at all, but you can actually restore it with the following steps:

  • Press on the Windows button
  • On the main screen, press on Photos
  • Press on Albums
  • Open the so called “8” photo album
  • Press Back until you are back into your app and try again.

This time you will see the saved pictures, and can perform your tests in more realistic conditions!

Restored Saved Pictures

Happy coding!
Laurent

 

© Geeks with Blogs or respective owner