【发布时间】:2017-02-13 23:03:15
【问题描述】:
我正在开发一个聊天应用程序:
如果用户点击图像,它将以全尺寸显示。调用如下方法:
Handle_Tapped():
void Handle_Tapped(object sender, System.EventArgs e)
{
try
{
Image image = sender as Image;
string filePath = String.Empty;
filePath = image.Source as FileImageSource;
Eva3Toolkit.CommonUtils.openImage(filePath);
}
catch (Exception ex)
{
throw ex;
}
}
哪些调用(取决于操作系统):
Android 中的openImage():
public void openImage(string filePath)
{
Intent sendIntent = new Intent(Intent.ActionView);
sendIntent.SetDataAndType(Android.Net.Uri.Parse("file:" + filePath), "image/*");
Forms.Context.StartActivity(Intent.CreateChooser(sendIntent, "Bild öffnen..."));
}
openImage() 在 iOS 中:
public void openImage(string filePath)
{
var firstController = ((UIApplicationDelegate)(UIApplication.SharedApplication.Delegate)).Window.RootViewController.ChildViewControllers[0].ChildViewControllers[1].ChildViewControllers[0];
var navcontroller = firstController as UINavigationController;
var docIC = UIDocumentInteractionController.FromUrl(new NSUrl(filePath, true));
docIC.Delegate = new DocInteractionC(navcontroller);
docIC.PresentPreview(true);
}
现在想在UWP中创建一个方法openImage(),但是不知道。我知道我很可能不得不将图像作为 StorageFile 而不是路径,因为只有 StorageFile 授予我打开图像的权限。
有没有办法在 UWP 中以全尺寸打开图像?我非常不想为此创建新视图。
【问题讨论】: