我正在使用ShareMediaTask来共享图像。我可以在将图像保存到我的电话库之后执行此操作但我想在将其保存到图库之前直接进行此操作。我怎样才能做到这一点 ?我已经完成了这个,但我不希望在分享之前打开照片选择器任务,我想直接分享它。
private void mnuShare_Click(object sender, EventArgs e)
{
using (MemoryStream stream = new MemoryStream())
{
WriteableBitmap bitmap = new WriteableBitmap(LayoutRoot, null);
bitmap.SaveJpeg(stream, bitmap.PixelWidth, bitmap.PixelHeight, 0, 100);
stream.Seek(0, SeekOrigin.Begin);
using (MediaLibrary mediaLibrary = new MediaLibrary())
mediaLibrary.SavePicture("Picture.jpg", stream);
}
MessageBox.Show("Picture Saved...");
var chooser = new Microsoft.Phone.Tasks.PhotoChooserTask();
chooser.Completed += chooser_Completed;
chooser.Show();
_fileName = e.ToString();
}
void ShowShareMediaTask(string path)
{
ShareMediaTask shareMediaTask = new ShareMediaTask();
shareMediaTask.FilePath = path;
shareMediaTask.Show();
}
void chooser_Completed(object sender, PhotoResult e)
{
_fileName = e.OriginalFileName.ToString();
if (e.TaskResult == TaskResult.OK)
{
ShareMediaTask shareMediaTask = new ShareMediaTask();
shareMediaTask.FilePath = _fileName;
shareMediaTask.Show();
}
答案 0 :(得分:0)
我只能将ShareMediaTask
用于图库中的照片。没有办法解决它。
但是,在Windows Phone 8.1中,您可以共享隔离存储中的任何文件,请查看http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh871371.aspx