[WindowsPhone] 隨貼即用 - 讀取相簿照片
2013-10-25
簡述 : 讀取手機內部相簿的相片,載入至Image物件
難度 : ★
範例敘述: 一顆按鈕,點擊後讀取手機內部相簿的相片,載入至Image物件
程式碼:
private void btnShareMedia_Click(object sender, RoutedEventArgs e)
{
PhotoChooserTask pct = new PhotoChooserTask();
pct.Completed += delegate(object pctSender, PhotoResult photoResult)
{
if (photoResult.TaskResult == TaskResult.OK)
{
var bitmap=new BitmapImage();
bitmap.SetSource(photoResult.ChosenPhoto);
Image物件.Source = bitmap;
}
else
{
MessageBox.Show("選取相片,未成功");
}
};
pct.ShowCamera = true;
pct.Show();
}
下載源碼:
標籤:
隨貼即用
,
C#
,
WindowsPhone
-- Yesterday I wrote down the code. I bet I could be your hero. I am a mighty little programmer. 如果這篇文章有幫助到您,簡單留個言,或是幫我按個讚,讓我有寫下去的動力...