PhotoChooserTask photoChooserTask = new PhotoChooserTask();
photoChooserTask.Completed += photoChooserTask_Completed;
photoChooserTask.ShowCamera = true;
photoChooserTask.Show();
void photoChooserTask_Completed(object sender, PhotoResult e)
{
if (e.TaskResult == TaskResult.OK)
{
ShowShareMediaTask(e.OriginalFileName);
}
}
void ShowShareMediaTask(string path)
{
ShareMediaTask shareMediaTask = new ShareMediaTask();
shareMediaTask.FilePath = path;
shareMediaTask.Show();
}
二。从系统相册里启动分享
http://msdn.microsoft.com/zh-cn/library/windows/apps/ff967563(v=vs.105).aspx
public class PicturesAlbum : ObservableCollection<FlowItem> { public PicturesAlbum() { using (var library = new MediaLibrary()) { PictureAlbumCollection allAlbums = library.RootPictureAlbum.Albums; PictureAlbum cameraRoll = allAlbums.Where(album => album.Name == "Saved Pictures").FirstOrDefault(); var CameraRollPictures = cameraRoll.Pictures; foreach (Picture _p in library.Pictures) { Stream _s = _p.GetImage(); BitmapImage _bi = new BitmapImage(); _bi.SetSource(_s); FlowItem _w = new FlowItem(); _w.Picture = _bi; _w.Name = _p.Name; _w.Date = _p.Date; ImageBrush ib = new ImageBrush(); ib.ImageSource = _bi; _w.BackupgroupPicture = ib; this.Add(_w); } } } }
加入图片到模拟器
https://wpdevkvk.wordpress.com/2014/07/19/adding-your-own-photos-to-windows-phone-8-1-emulator/