点击图片,< image source =" .....">并在Photo App中打开 [英] Click on Image, <image source="....."> and open in Photo App

查看:61
本文介绍了点击图片,< image source =" .....">并在Photo App中打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在页面上有一张图片。 我希望用户能够点击它,它将在"照片"中打开。 Windows 10附带的应用程序。 这是可能的,如果是这样我将如何去做。

I have an image on a page.  I want the user to be able to click on it and it will open in the "Photo" app that comes with Windows 10.  Is that possible and if so how would I go about doing it.

谢谢

推荐答案

你好7VN,

欢迎来到
开发通用Windows应用论坛
!请使用  标记 
发布到此论坛时,谢谢!

您可以使用  LaunchFileAsync(IStorageFile) 图片
Tapped中的方法
event to 启动与指定文件关联的默认应用。

You can use the LaunchFileAsync(IStorageFile) method in the Image's Tapped event to start the default app associated with the specified file.

 例如以下代码,

 such as the following code,

        private async void Image_Tapped(object sender, TappedRoutedEventArgs e)
        {
            var file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync("pic.png");
            if (file != null)
            {
                // Launch the retrieved file
                var success = await Windows.System.Launcher.LaunchFileAsync(file);

                if (success)
                {
                    // File launched
                }
                else
                {
                    // File launch failed
                }
            }
            else
            {
                // Could not find file
            }
        }

您还可以添加
LauncherOptions
来设置显示选择器的选项,以便用户可以选择应用程序,

You can also add the LauncherOptions to set the option to show the picker, so that user can select the apps,

        private async void Image_Tapped(object sender, TappedRoutedEventArgs e)
        {

            var file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync("pic.png");
            var options = new Windows.System.LauncherOptions();
            options.DisplayApplicationPicker = true;
            if (file != null)
            {
                // Launch the retrieved file
                var success = await Windows.System.Launcher.LaunchFileAsync(file, options);

                if (success)
                {
                    // File launched
                }
                else
                {
                    // File launch failed
                }
            }
            else
            {
                // Could not find file
            }
        }

祝你好运,

Breeze


这篇关于点击图片,< image source =" .....">并在Photo App中打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆