本文介绍了[Win 8.1]分享图像和文字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Windows 8.1上共享图像和文字?

注意:图像不是使用开放式选择器捕获的,而是已经在包中。

How to share images and text on Windows 8.1?
Note: the image is not captured using the open-picker, but already in the package.

例如:

如果我点击分享按钮,它将分享封面的图像,并在分享时出现句子。

If I click on the share button, it will share an image of the cover and also appeared sentence when shared.

句子是杂志。

推荐答案

        public MainPage()
        {
            this.InitializeComponent();
            DataTransferManager.GetForCurrentView().DataRequested += OnData;
        }

        private async void OnData(DataTransferManager sender, DataRequestedEventArgs args)
        {
            DataPackage requestData = args.Request.Data;
            requestData.Properties.Title = "Share";
            requestData.Properties.Description = "Get the magazine";

            // It's recommended to use both SetBitmap and SetStorageItems for sharing a single image
            // since the target app may only support one or the other.
            var uri = new Uri("ms-appx:///Assets/StoreLogo.scale-100.png");
            var imageFile = await StorageFile.GetFileFromApplicationUriAsync(uri);

            List<IStorageItem> imageItems = new List<IStorageItem>();
            imageItems.Add(imageFile);
            requestData.SetStorageItems(imageItems);

            RandomAccessStreamReference imageStreamRef = RandomAccessStreamReference.CreateFromFile(imageFile);
            requestData.Properties.Thumbnail = imageStreamRef;
            requestData.SetBitmap(imageStreamRef);
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            DataTransferManager.ShowShareUI();
        }


这篇关于[Win 8.1]分享图像和文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-25 09:20