9

I am using CameraCaptureUI for opening camera in my application; Here is the code what iam using

        var camera = new CameraCaptureUI();
        camera.PhotoSettings.AllowCropping = false;
        var file = await camera.CaptureFileAsync(CameraCaptureUIMode.Photo);
        if (file != null)
        {
            var fileStream = await file.OpenAsync(FileAccessMode.Read);
            var bitmapImage = new BitmapImage();
            bitmapImage.SetSource(fileStream);
            var sourceImage = new WriteableBitmap(bitmapImage.PixelWidth, bitmapImage.PixelHeight);
            var imageStream = await file.OpenAsync(FileAccessMode.Read);
            sourceImage.SetSource(imageStream);

        }

But the issue is not with camera. During the time of camera open. If we open settings charm the await function cancels var file = await camera.CaptureFileAsync(CameraCaptureUIMode.Photo); [File returns null] and hides the CameraCapture UI. What i am trying to do is i need to open my camera always even if the user opens the charm. How i can achieve this in WinRT

Jerry Nixon
  • 31,313
  • 14
  • 117
  • 233
StezPet
  • 2,430
  • 2
  • 27
  • 49
  • Have you noticed, default camera app is not facing such issue. – Farhan Ghumra May 29 '13 at 07:30
  • Yups. The same issue is present in CameraCaptureUI and FileOpenPicker. You can easily replicate this issues in Dropbox app by MS. Also the sample in the MSDN here is the link http://code.msdn.microsoft.com/windowsapps/CameraCaptureUI-Sample-845a53ac#content – StezPet May 29 '13 at 07:34

1 Answers1

1

To solve your problem, you need to stop using the CameraCaptureUI and start using the <CaptureElement/> in a UI you specifically design for your special scenario.

I wrote this up in an article to help. Here.

Best of luck!

Jerry Nixon
  • 31,313
  • 14
  • 117
  • 233