title: PhotoChooserTask + Navigation
body: <p>I taken two Images  &amp; added event (MouseButtonDown) for them.
  When first image handles event to open Gallery. Second image handles events for open camera.
  When user has choosed his image from the gallery, I want to navigate to next page. Its navigates. But before completing navigation process, it displays MainPage &amp; then moves toward next page. I didnt want to display the MainPage once user chooses the image from the gallery. 
  Plz help.
  Thanks in advance.</p>
  
  <p>public partial class MainPage : PhoneApplicationPage</p>
  
  <pre><code>{
      PhotoChooserTask objPhotoChooser;
      CameraCaptureTask cameraCaptureTask;
  
      // Constructor
      public MainPage()
      {
          InitializeComponent();
  
          objPhotoChooser = new PhotoChooserTask();
          objPhotoChooser.Completed += new EventHandler&lt;PhotoResult&gt;(objPhotoChooser_Completed);
  
          cameraCaptureTask = new CameraCaptureTask();
          cameraCaptureTask.Completed += new EventHandler&lt;PhotoResult&gt;(objCameraCapture_Completed);         
      }
  
      void objPhotoChooser_Completed(object sender, PhotoResult e)
      {
          if (e != null &amp;&amp; e.TaskResult == TaskResult.OK)
          {
              //Take JPEG stream and decode into a WriteableBitmap object                
              App.CapturedImage = PictureDecoder.DecodeJpeg(e.ChosenPhoto);
  
              //Delay navigation until the first navigated event
              NavigationService.Navigated += new NavigatedEventHandler(navigateCompleted);
          }
      }
  
  
      void navigateCompleted(object sender, EventArgs e)
      {
          //Do the delayed navigation from the main page
          this.NavigationService.Navigate(new Uri("/ImageViewer.xaml", UriKind.RelativeOrAbsolute));
          NavigationService.Navigated -= new NavigatedEventHandler(navigateCompleted);
      }
  
  
      void objCameraCapture_Completed(object sender, PhotoResult e)
      {
          if (e.TaskResult == TaskResult.OK)
          {
              //Take JPEG stream and decode into a WriteableBitmap object                
              App.CapturedImage = PictureDecoder.DecodeJpeg(e.ChosenPhoto);
  
              //Delay navigation until the first navigated event
              NavigationService.Navigated += new NavigatedEventHandler(navigateCompleted);          
          }
      }
  
  
      protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
      {
          e.Cancel = true;
      }
  
  
      private void image1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
      {
          objPhotoChooser.Show();
      }
  
  
      private void image2_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
      {
          cameraCaptureTask.Show();
      }
  </code></pre>