簡述 : 讀取手機內部相簿的相片,載入至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();
}
下載源碼:
--
The bug existed in all possible states. Until I ran the code.
如果這篇文章有幫助到您幫我分享一下,讓我有寫下去的動力...