Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Whilst <code>PhotoChooserTask</code> will only allow the user to select one image from their library (or capture a new one from their camera if you set <code>ShowCamera</code> to 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?)</p> <pre><code>public partial class MainPage : PhoneApplicationPage { public class SelectedPhoto : IDisposable { public Stream Data { get; private set; } public string Name { get; private set; } public BitmapImage Image { get; private set; } public SelectedPhoto(string name, Stream photo) { Name = name; Data = new MemoryStream(); photo.CopyTo(Data); Image = new BitmapImage(); Image.SetSource(Data); } public void Dispose() { Data.Dispose(); } } private List&lt;SelectedPhoto&gt; _selectedPhotos = new List&lt;SelectedPhoto&gt;(); private PhotoChooserTask photoChoserTask; // Constructor public MainPage() { InitializeComponent(); photoChoserTask = new PhotoChooserTask(); photoChoserTask.Completed += new EventHandler&lt;PhotoResult&gt;(photoChooserTask_Completed); ProcessImages.IsEnabled = false; ImageListBox.ItemsSource = _selectedPhotos } void photoChooserTask_Completed(object sender, PhotoResult e) { if (e.TaskResult == TaskResult.OK) { _selectedPhotos.Add(new SelectedPhoto(e.OriginalFileName, e.ChosenPhoto); Button.IsEnabled = _selectedPhotos.Count &lt; 9; ProcessImages.IsEnabled = _selectedPhotos.Count == 9; } } private void Button_Click(object sender, RoutedEventArgs e) { { try { photoChoserTask.Show(); } catch (System.InvalidOperationException) { MessageBox.Show("An error occurred."); } } } private void ProcessImages_Click(object sender, RoutedEventArgs e) { MessageBox.Show("Doing something with your images... please wait..."); } } </code></pre> <p>In your XAML rather than having a single Image you'd want to put an Image inside a <code>ListBox</code>'s <code>DataTemplate</code> and show all of the user's currently entered images (probably with an option to erase an image and add a different image instead). Eg;</p> <pre><code> &lt;ListBox x:Name="ImageListBox"&gt; &lt;ListBox.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;StackPanel&gt; &lt;Image Source="{Binding Image}" /&gt; &lt;TextBlock Text="{Binding Name}" /&gt; &lt;/StackPanel&gt; &lt;/DataTemplate&gt; &lt;/ListBox.ItemTemplate&gt; &lt;/ListBox&gt; &lt;Button x:Name="ProcessImages" Click="ProcessImages_Click" /&gt; </code></pre> <p>If the requirement is to have <em>up to</em> 9 images, I'd prefer this approach, over a custom multi-select image selector, for a few reasons reasons;</p> <ol> <li>It provides the user with a consistent user experience - the same as they'd get in any other app</li> <li>By making use of the <code>MediaLibrary</code> your application will require the <code>ID_CAP_MEDIALIB</code> capability (Shows up as "Access media library", I believe).</li> <li>I'd find this method a bit less work than a full blown media choser.</li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload