-
Notifications
You must be signed in to change notification settings - Fork 501
/
Copy pathScenario7.xaml.cs
83 lines (76 loc) · 3.09 KB
/
Scenario7.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
using SDKTemplate;
using System;
using Windows.ApplicationModel.DataTransfer;
namespace Controls_WebView
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class Scenario7 : SDKTemplate.Common.LayoutAwarePage
{
// A pointer back to the main page. This is needed if you want to call methods in MainPage such
// as NotifyUser()
MainPage rootPage = MainPage.Current;
DataTransferManager dataTransferManager = null;
public Scenario7()
{
this.InitializeComponent();
}
/// <summary>
/// Invoked when this page is about to be displayed in a Frame.
/// </summary>
/// <param name="e">Event data that describes how this page was reached. The Parameter
/// property is typically used to configure the page.</param>
protected override void OnNavigatedTo(NavigationEventArgs e)
{
WebView7.LoadCompleted += WebView7_LoadCompleted;
WebView7.Navigate(new Uri("http://www.wsj.com"));
}
void WebView7_LoadCompleted(object sender, NavigationEventArgs e)
{
WebView7.Visibility = Windows.UI.Xaml.Visibility.Visible;
BlockingRect.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
ProgressRing1.IsActive = false;
}
/// <summary>
/// This is the click handler for the 'Share Content' button.
/// <param name="sender"></param>
/// <param name="e"></param>
//<snippetDataTransferPackage>
private void Share_Click(object sender, RoutedEventArgs e)
{
dataTransferManager = DataTransferManager.GetForCurrentView();
dataTransferManager.DataRequested += dataTransferManager_DataRequested;
DataTransferManager.ShowShareUI();
}
void dataTransferManager_DataRequested(DataTransferManager sender, DataRequestedEventArgs args)
{
DataRequest request = args.Request;
DataPackage p = WebView7.DataTransferPackage;
if (p.GetView().Contains(StandardDataFormats.Text))
{
p.Properties.Title = "WebView Sharing Excerpt";
p.Properties.Description = "This is a snippet from the content hosted in the WebView control";
request.Data = p;
}
else
{
request.FailWithDisplayText("Nothing to share");
}
dataTransferManager.DataRequested -= dataTransferManager_DataRequested;
}
//</snippetDataTransferPackage>
}
}