C#

publicpartialclassPhontosAndCameras:PhoneApplicationPage{CameraCaptureTaskcamera=newCameraCaptureTask();PhotoChooserTaskphoto=newPhotoChooserTask();publicPhontosAndCameras(){InitializeComponent();camera.Completed+=newEventHandler<PhotoResult>(photo_Completed);photo.Completed+=newEventHandler<PhotoResult>(photo_Completed);}voidphoto_Completed(objectsender,PhotoResulte){BitmapImagebitmap=newBitmapImage();bitmap.SetSource(e.ChosenPhoto);p_w_picpath2.Source=bitmap;path.Text=e.OriginalFileName;}privatevoidButton_Click(objectsender,RoutedEventArgse){camera.Show();}privatevoidButton_Click_1(objectsender,RoutedEventArgse){photo.ShowCamera=true;photo.Show();}}

XAML

<Gridx:Name="LayoutRoot"Background="Transparent"><Grid.RowDefinitions><RowDefinitionHeight="Auto"/><RowDefinitionHeight="Auto"/><RowDefinitionHeight="Auto"/><RowDefinitionHeight="Auto"/></Grid.RowDefinitions><TextBlockName="path"Text="显示路径"></TextBlock><ImageName="p_w_picpath2"Grid.Row="1"></Image><ButtonContent="拍照"Grid.Row="2"Width="200"Click="Button_Click"></Button><ButtonContent="选择照片"Grid.Row="3"Width="200"Click="Button_Click_1"></Button></Grid>