Am making an application in WP7 using Windows Phone SDK 7.1 / C#
Am using photo chooser task. But I want to select 9 images and here I can select only one Image.
How can I select 9 images at a stretch?
Please Help me, here is my code:
public partial class MainPage : PhoneApplicationPage
{
PhotoChooserTask photoChoserTask;
// Constructor
public MainPage()
{
InitializeComponent();
photoChoserTask = new PhotoChooserTask();
photoChoserTask.Completed +=
new EventHandler<PhotoResult>(photoChooserTask_Completed);
}
void photoChooserTask_Completed(object sender, PhotoResult e)
{
if (e.TaskResult == TaskResult.OK)
{
y.Text= (e.ChosenPhoto.Length.ToString());
//Code to display the photo on the page in an image control named myImage.
//System.Windows.Media.Imaging.BitmapImage bmp =
//new System.Windows.Media.Imaging.BitmapImage();
//bmp.SetSource(e.ChosenPhoto);
//myImage.Source = bmp;
}
}
private void Button_Click(object sender, RoutedEventArgs e)
{
{
try
{
photoChoserTask.Show();
}
catch (System.InvalidOperationException )
{
MessageBox.Show("An error occurred.");
}
}
}
}
}
Whilst
PhotoChooserTaskwill only allow the user to select one image from their library (or capture a new one from their camera if you setShowCamerato true) another option would be to continue to allow the user to iteratively select images and not allow them to continue until they have selected 9 (I believe that’s the requirement you’re after?)In your XAML rather than having a single Image you’d want to put an Image inside a
ListBox‘sDataTemplateand show all of the user’s currently entered images (probably with an option to erase an image and add a different image instead). Eg;If the requirement is to have up to 9 images, I’d prefer this approach, over a custom multi-select image selector, for a few reasons reasons;
MediaLibraryyour application will require theID_CAP_MEDIALIBcapability (Shows up as “Access media library”, I believe).