Recent Posts
- November 2014 (1)
- January 2014 (1)
- October 2013 (1)
- May 2013 (1)
- February 2013 (2)
- October 2012 (1)
- August 2012 (1)
- July 2012 (4)
- June 2012 (13)
Blog Stats
- 36,360 hits
Write your code smartly
Here i will tell you how to invoke Camera in Windows phone application. Its as simple as you can use a camera in your cell phone.
So now add a button any where in your Windows Phone application from toolbox and double click it to get the click event handler or find the click event from its properties windows show in previous posts.
Please add the following namespace on top of your CS file or code file
using Microsoft.Phone.Tasks;
Add following code on the click event of the button.
private void button1_Click(object sender, RoutedEventArgs e)
{
CameraCaptureTask cmt = new CameraCaptureTask();
cmt.Completed += new EventHandler<PhotoResult>(cmt_Completed);
cmt.Show();
}
The Camera will be launched after clicking button with a dummy Black object moving around a white screen. by pressing the Capture button you can capture the image. You can Play with the image captured in your application like displaying it on image control.
Put the below code in Camera photo result event
void cmt_Completed(object sender, PhotoResult e)
{
//throw new NotImplementedException();
BitmapImage bi = new BitmapImage();
bi.SetSource(e.ChosenPhoto);
image1.Source = bi;
}
Enjoy Happy Coding !
Windows Phone applications are created using C# language on .NET platform 4.0 or above. Simply you must have Visual Studio 2010 service pack 1 installed on your system, if not you can find it fromHere. This down loader will install Windows Phone SDK along with Visual Studio Express limited for Windows phone development. Along with the SDK the Emulator for testing your apps live will also be installed for which you required at-least 2 GB memory. Once you have configured all the setup you are ready to build your first Windows Phone application.
Open Visual Studio Express for Windows Phone and click > File from the menu. Then new Project > Silverlight for Windows Phone .
Now here you can select different type of controls offered by Windows Phone, it includes Panorama, Pivot and simple application. Here how it looks like.
Give the name and location and then press OK. You will see this design view of your first application.
here you can see 2 blocks divided, one is the phone showing the Windows phone and second on the right side is the Silver light code (XAML) generated when you make changes on the phone design by dragging controls from toolbar to the phone. Toolbar is on the left side having common controls . Using these controls you can develop a Windows Phone application. In further posts i will be telling you how you can create a working simple app using XAML and C# code so stay tune and queries you can post comments below.
Happy Coding !