I am trying to retrieve an image from the phone library and set it as the page background using the following code
private void selectImageFromMediaLib()
{
selectphoto = new PhotoChooserTask();
selectphoto.Completed += new EventHandler<PhotoResult>(selectphoto_Completed);
selectphoto.Show();
}
private void selectphoto_Completed(object sender, PhotoResult e)
{
if (e.TaskResult == TaskResult.OK)
{
backgroundUri = new Uri(e.OriginalFileName, UriKind.Absolute);
var bitmap = new BitmapImage(backgroundUri);
ImageBrush imageBrush = new ImageBrush();
imageBrush.ImageSource = bitmap;
this.LayoutRoot.Background = imageBrush;
}
}
However, the page background turns black so the photo was not retrieved/created correctly. What is the correct path for the URI to the device library? Isn't using UriKind.Absolute
enough?