private void fileChooseButton_Click(object sender, EventArgs e) { // 画像を選ぶ var task = new PhotoChooserTask { PixelHeight = 800, PixelWidth = 600, ShowCamera = true }; task.Completed += (ps, pe) => { if (pe.TaskResult == TaskResult.OK && pe.Error == null) { this.originBitmap = ConvertToWriteableBitmap(pe.ChosenPhoto); this.editedBitmap = ApplyYey(Grayscare(this.originBitmap)); this.pictureImage.Source = editedBitmap.ToBitmapImage(); this.fileSaveButton.IsEnabled = true; this.startMessageGrid.Visibility = System.Windows.Visibility.Collapsed; } else if (pe.TaskResult == TaskResult.Cancel && pe.Error != null) { MessageBox.Show( "PCでZune Softwareと同期中の可能性があります。\n" + "Zune Softwareを終了するか、端末をPCから切断してもう一度実行して下さい。", "エラー", MessageBoxButton.OK); } }; task.Show(); }