2011-05-06 52 views
2

我想打开Windows Phone 7相机,拍摄一张照片,然后处理该照片。但问题是,当我尝试重写OnChooserReturn功能它给我的错误no suitable method found to override还当我想捕捉从我用这个相机有什么回报:虽然我使用无法找到ChooserEventArgs类

ChooserEventArgs<PhotoResult> args = new ChooserEventArgs<PhotoResult>() 

它给我的错误The type or namespace name 'ChooserEventArgs' could not be found (are you missing a using directive or an assembly reference?)这两条指令

using Microsoft.Phone.Controls; 
using Microsoft.Phone.Tasks; 

问题是什么,我该如何解决这些问题?

+0

是的,我的参考是Mix 2010视频 – 2011-05-07 05:58:08

回答

3

这听起来像你正在尝试使用旧的SDK或至少基于过时的SDK的指南。要让手机启动相机,然后引用拍摄的图像,请使用CameraCaptureTask。您将需要后续的使用说明:

using Microsoft.Phone.Tasks; 
using System.Windows.Media.Imaging; 

某处在你的代码(大概在一个按钮单击事件),你这样做是为了启动相机:

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

然后你处理完成的情况下这样(假设你有一个Image控件命名的图像):

void cct_Completed(object sender, PhotoResult e) 
{ 
    if (e.TaskResult == TaskResult.OK) 
    { 
     BitmapImage bimg = new BitmapImage(); 
     bimg.SetSource(e.ChosenPhoto); 
     this.image.Source = bimg; 
    }    
} 

文档在这里:http://msdn.microsoft.com/en-us/library/microsoft.phone.tasks.cameracapturetask(v=VS.92).aspx