2013-05-29 71 views
9

我使用CameraCaptureUI在我的應用程序中打開相機;這裏是我使用的代碼打開設置的魅力,而相機打開關閉相機在Windows 8/WinRT

 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); 

     } 

但問題不在於相機。在相機打開的時候。如果我們打開設置魅力等待功能取消var file = await camera.CaptureFileAsync(CameraCaptureUIMode.Photo); [文件返回空],並隱藏CameraCapture用戶界面。我想要做的是,即使用戶打開魅力,我也需要始終打開相機。如何在WinRT中實現此目標

+0

你有沒有注意到,默認的相機應用程序是不是面臨這樣的問題。 – Xyroid

+0

Yups。 CameraCaptureUI和FileOpenPicker中存在相同的問題。 MS可以輕鬆地在Dropbox應用程序中複製這些問題。此外,MSDN中的示例是鏈接http://code.msdn.microsoft.com/windowsapps/CameraCaptureUI-Sample-845a53ac#content – StezPet

回答

1

要解決您的問題,您需要停止使用CameraCaptureUI並在專門爲您的特殊場景設計的用戶界面中使用<CaptureElement/>

我在一篇文章中寫道,以幫助。 Here

祝你好運!