Bind ListBox Control With Songs from Media Library

Posted: March 15, 2012 in Windows Phone 7 & Mango

To get a t of all songs from your Media Library and bind it to a ListBox control, first add the control in your XAML file as follows:

<ListBox x:Name="myListBox" />
using Microsoft.Xna.Framework.Media;

private void ListSongs()
{
  MediaLibrary myLib = new MediaLibrary();
  var mySongName = (from m in myLib.Songs select m.Name).ToList();
  myListBox.ItemsSource = mySongName;
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s