开发者

Unable to find ChooserEventArgs class

I want to open windows phone 7 camera, take a sn开发者_运维知识库ap and then manipulate that picture. But the problem is when I try to override the OnChooserReturn function it gives me the error no suitable method found to override also when I want to capture what returns from the camera I use this :

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

It gives me the error The type or namespace name 'ChooserEventArgs' could not be found (are you missing a using directive or an assembly reference?) although I am using these two directives

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

What is the problem and how can I solve these issues?


It sounds like you are trying to use an old SDK or at least a guide based on an outdated SDK. To have the phone launch the Camera and then to reference the captured image you use the CameraCaptureTask. You will need the following Using statements:

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

Somewhere in your code (presumably in a button click event) you do this to launch the camera:

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

Then you handle the completed event like this (assuming you have an Image control named 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;
    }            
}

Documentation Here: http://msdn.microsoft.com/en-us/library/microsoft.phone.tasks.cameracapturetask(v=VS.92).aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜