写真の選択と撮影
C#
XAML
- public partial class PhontosAndCameras : PhoneApplicationPage
- {
- CameraCaptureTask camera=new CameraCaptureTask();
- PhotoChooserTask photo=new PhotoChooserTask();
-
- public PhontosAndCameras()
- {
- InitializeComponent();
-
- camera.Completed += new EventHandler<PhotoResult>(photo_Completed);
- photo.Completed += new EventHandler<PhotoResult>(photo_Completed);
- }
-
- void photo_Completed(object sender, PhotoResult e)
- {
- BitmapImage bitmap = new BitmapImage();
- bitmap.SetSource(e.ChosenPhoto);
- image1.Source = bitmap;
- path.Text = e.OriginalFileName;
- }
-
-
- private void Button_Click(object sender, RoutedEventArgs e)
- {
- camera.Show();
- }
-
- private void Button_Click_1(object sender, RoutedEventArgs e)
- {
- photo.ShowCamera = true;
- photo.Show();
- }
- }
XAML
- <Grid x:Name="LayoutRoot" Background="Transparent">
- <Grid.RowDefinitions>
- <RowDefinition Height="Auto"/>
- <RowDefinition Height="Auto"/>
- <RowDefinition Height="Auto"/>
- <RowDefinition Height="Auto"/>
- </Grid.RowDefinitions>
- <TextBlock Name="path" Text=" "></TextBlock>
- <Image Name="image1" Grid.Row="1" ></Image>
- <Button Content=" " Grid.Row="2" Width="200" Click="Button_Click"></Button>
- <Button Content=" " Grid.Row="3" Width="200" Click="Button_Click_1"></Button>
- </Grid>