示例#1
0
        private async void OnShareToClipboard(ShareProviderOperation operation)
        {
            var webLink = await operation.Data.GetWebLinkAsync();

            var dataPackage = new DataPackage();

            dataPackage.SetText(webLink.ToString());

            await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
            {
                ClipboardEx.TrySetContent(dataPackage);
                operation.ReportCompleted();
            });
        }
示例#2
0
        private async void OnShareToContosoChat(ShareProviderOperation operation)
        {
            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
            {
                ShareCompletedText.Text = "";

                // Obtain the text from the data package. This should match
                // the information placed in it by the GetShareContent method.
                String text = await operation.Data.GetTextAsync();

                // The app can display custom UI to complete the Share operation.
                // Here, we simply display a progress control and delay for a while,
                // to simulate posting to the Contoso Chat service.
                ProgressControl.Visibility = Visibility.Visible;
                await Task.Delay(TimeSpan.FromSeconds(2));

                // All done. Show the success message.
                ProgressControl.Visibility = Visibility.Collapsed;
                ShareCompletedText.Text    = $"Your message '{text}' has been shared with Contoso Chat.";

                // Completing the operation causes ShareCompleted to be raised.
                operation.ReportCompleted();
            });
        }
 public abstract void OnShare(ShareProviderOperation operation);