Search code examples
c#windows-phone-8emulationphotos

Getting Local Photos Windows Phone 8 Emulator


So I have taken some Photos on my windows phone emulator and I am then trying to find them in my application. So Far I have:

PictureCollection CameraRollPictures;
using (var library = new MediaLibrary())
{
    //taking all albums
     PictureAlbumCollection allAlbums = library.RootPictureAlbum.Albums;
     //taking Camera Roll album separately from all album
     PictureAlbum cameraRoll = allAlbums.Where(album => album.Name == "Camera Roll").FirstOrDefault();
     // here you will get camera roll picture list
     CameraRollPictures = cameraRoll.Pictures;
}

But this keeps crashing because cameraRoll = null. Is this feature available on WP8 emulator or am I doing something wrong?

My method to get photos is from this stackoverflow question

EDIT I have also tried album.Name == "Camera Roll"

Windows Phone Photos


Solution

  • So the answer was simple... My method worked perfectly but I needed to:

    • go into the WMAppManifest.Xml
    • go to Capabilities
    • tick ID_CAP_MEDIALIB_PHOTO

    This provides read-only access to photos in the media library