Camera Capture in WP7 Mango

I recently upgraded the WP7 app to Mango and am having problems with the camera. The code below is used to work with 7.0, but on 7.1 the completed handler fires before the dialog is shown, so I can not fix the result. After you take the photo, the phone displays "Resume ...", which he never did.

var dlg = new CameraCaptureTask();
            dlg.Completed += (s, e) =>
            {
                if (e.TaskResult == TaskResult.OK) {
                    BitmapImage bmp = new BitmapImage();
                    bmp.SetSource(e.ChosenPhoto);
                    //var img = new Image();
                    //img.Source = bmp;

                    string caption = string.Empty;
                    var inputDialog = new InputPrompt()
                    {
                        Title = "Caption",
                        Message = "Enter caption/description for snapshot",
                    };
                    inputDialog.Completed += (ss, ee) =>
                                                 {
                                                     if (ee.PopUpResult == PopUpResult.Ok)
                                                     {
                                                         caption = ee.Result;

                                                         var snap = SnapshotBLL.AddSnapshot(recipeId, bmp, caption);
                                                         onComplete(null, new SnapshotEventArgs(snap));
                                                     }
                                                 };
                    inputDialog.Show();
                }
            };
            dlg.Show();

The MSDN docs show a change in my code, but I can no longer get the result of the camera capture task.

+5
source share
1 answer

Assuming your sample comes from a single method, I would not expect it to work before Mango.

CameraCaptureTask , .
- :

public partial class MainPage : PhoneApplicationPage
{
    private CameraCaptureTask cct = new CameraCaptureTask();

    public MainPage()
    {
        InitializeComponent();

        cct.Completed += new EventHandler<PhotoResult>(cct_Completed);
    }

    private void cct_Completed(object sender, PhotoResult e)
    {
        // Do whatever here
    }

    private void SomeEventHandler(object sender, RoutedEventArgs e)
    {
        cct.Show();
    }
}

7.0, 7.1

+5

All Articles