Over a million developers have joined DZone.

Accessing Pictures from Media Library in Windows Phone

DZone's Guide to

Accessing Pictures from Media Library in Windows Phone

· Mobile Zone
Free Resource

Discover how to focus on operators for Reactive Programming and how they are essential to react to data in your application.  Brought to you in partnership with Wakanda

You may come across a requirement to access the entire picture saved in Media Library of Windows Phone. Media Library can be access using MediaLibrary class.

To work with MediaLibrary class you need to add reference of Microsoft.Xna.Framework. This class is defined in namespace Microsoft.Xna.Framework.Media namespace.

To work with MediaLibrary, you need to make instance of MediaLibrary class as below,


Pictures property of MediaLibrary class returns all the images as Picture. You can iterate to all images as below,


Image can be fetch as stream inside foreach look as below,


You can create Image from returend stream as below.


Eventually you can set imageToShow as source of Image control. For your reference below code will add all the pictures from Media Library in a listbox called lstImageFromMediaLibrary

MediaLibrary m = new MediaLibrary();

foreach (var r in m.Pictures)
Stream imageStream = r.GetImage();

var imageToShow = new Image()
Source = PictureDecoder.DecodeJpeg(r.GetImage())


You can access Media Library on emulator only in debugmode. In this way you can access all the images from Media library. I hope this post is useful. Thanks for reading.

Learn how divergent branches can appear in your repository and how to better understand why they are called “branches".  Brought to you in partnership with Wakanda


Published at DZone with permission of Dhananjay Kumar, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.


Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.


{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}