使用PhotoChooserTask的 [英] Using of PhotoChooserTask

查看:83
本文介绍了使用PhotoChooserTask的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的Windows Phone应用程序图像(如内容)的列表。我怎么能看到他们PhotoChooserTask?

I have a list of images (as content) in my Windows Phone application. How can I see them with PhotoChooserTask?

推荐答案

下面是一个按钮,点击发射任务的基础和粗糙的例子。

Here is the basic and rough example of firing the task from a button click.

下面的代码使用一个按钮单击事件来触发PhotoChooserTask(),然后选定的图像放到一个图像控件。

The below code uses a button click event to fire the PhotoChooserTask() and then place the selected image into a image control.

您需要使用

using Microsoft.Phone.Tasks;

和再使用的代码如下:

public MainPage()
    {
    InitializeComponent();
        photoChooserTask = new PhotoChooserTask();
        photoChooserTask.Completed += new EventHandler<PhotoResult>(photoChooserTask_Completed);
        }
        private void photochooserbtn_Click(object sender, RoutedEventArgs e)
         {
         photoChooserTask.Show();
         }
        void photoChooserTask_Completed(object sender, PhotoResult e)
         {
         if (e.TaskResult == TaskResult.OK)
         {
         System.Windows.Media.Imaging.BitmapImage bmp =new     System.Windows.Media.Imaging.BitmapImage();
         bmp.SetSource(e.ChosenPhoto);
         imagecontrol.Source = bmp;
         }
       }

这篇关于使用PhotoChooserTask的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆