The pictures should be picked up from the camera roll in Windows Phone 8.
This does not exist out of the box. It took some XAML searching and programming
to get it working correctly. Thanks to Andy_TeamG for the tip!
XAML:
<Image x:Name="Image" />
<ListBox.ItemTemplate OnSelectionChanged="lstImages_SelectionChanged">
<DataTemplate>
<Image Source="{Binding ImageFile}" Width="100" Height="100"/>
DataTemplate>
ListBox.ItemTemplate>
Code Behind
private void GetImages()
{
MediaLibrary mediaLibrary = new MediaLibrary();
var pictures = mediaLibrary.Pictures;
foreach (var picture in pictures)
{
BitmapImage image = new BitmapImage();
image.SetSource(picture.GetImage());
MediaImage mediaImage = new MediaImage();
mediaImage.ImageFile = image;
lstImages.Items.Add(mediaImage);
}
private void lstImages_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
MediaLibrary mediaLibrary = new MediaLibrary();
BitmapImage image = new BitmapImage();
image.SetSource(mediaLibrary.Pictures[lstImages.SelectedIndex].GetImage());
imgSelectedPhoto.Source = image;
}
Source:
http://andy-teamg.blogspot.com/2010/07/windows-phone-7-selecting-device-photos.html
No comments:
Post a Comment