Click here to Skip to main content
15,868,065 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How we can Open window phone camera in our window phone app using Xaml & C# ???
Posted

The XAML part is largely irrelevant - that's defining the layout of your page and the items for interactions. The important bit is in the C# side. Generally, if you're going to just take a quick snapshot from your camera and the camera portion isn't the main part of your application, you're going to want to use the camera capture task.

From memory, it's going to look something like this:
C#
using Microsoft.Phone.Tasks;
using System.Windows.Media.Imaging;
public class CaptureFromCamera
{
  private CameraCaptureTask camera = new CameraCaptureTask();

  public CaptureFromCamera()
  {
    camera.Completed += PhotoTaken;
  }

  public BitmapImage Photo { get; private set; }

  public void Show()
  {
    camera.Show();
  }
  
  private void PhotoTaken(object sender, PhotoResult result)
  {
    Photo = new BitmapImage();
    Photo.SetSource(result.ChosenPhoto);
  }
}
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 15-Apr-15 18:41pm    
5ed.
—SA
Pete O'Hanlon 17-Apr-15 5:41am    
Thanks.
You can use the PhotoCamera[^] class.
Here is an example - Using Cameras in Your Windows Phone Application[^].

There is a minor difference between CaptureCameraTask and PhotoCamera classes that you could be aware of - How to use the camera capture task for Windows Phone 8[^].
 
Share this answer
 
v2
Comments
Pete O'Hanlon 16-Apr-15 9:17am    
My 5
Abhinav S 16-Apr-15 13:30pm    
Thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900