I have an application with only one button. When user clicks the button, a photo chooser should be launched.
The following is my code
PhotoChooserTask photoChooserTask;
BitmapImage image;
Page_Launch event
{
this.photoChooserTask = new PhotoChooserTask();
this.photoChooserTask.ShowCamera = true;
this.photoChooserTask.PixelHeight = 100;
this.photoChooserTask.PixelWidth = 100;
this.photoChooserTask.Completed += new EventHandler<PhotoResult>(photoChooserTask_Completed);
}
button_click event
{
this.photoChooserTask.Show();
}
private void photoChooserTask_Completed(object sender, PhotoResult e)
{
this.image = new BitmapImage();
this.image.SetSource(e.ChosenPhoto);
}
Everything is fine when I start debuging on WP emulator. I can choose a photo from photo library or capture one, crop and save the photo. But when I run debuging on my WP device, I always get e.ChosenPhoto ArgumentNullException error after clicking the button.
Has anyone got same issue?
Are you writing this code in the Application launch event ??
Did you tried by adding the photochoosertask in a page.
try this pasting in to the MyPage.xaml.cs file