diff --git a/README.md b/README.md
index 99b97ccba9..9222bd0578 100644
--- a/README.md
+++ b/README.md
@@ -189,6 +189,7 @@ For additional Windows samples, see [Windows on GitHub](http://microsoft.github.
WebView control (HTML)
+ WebView control (XAML)
Window resizing
@@ -445,31 +446,32 @@ For additional Windows samples, see [Windows on GitHub](http://microsoft.github.
Networking and web services
+ Advertising
Background transfer
DatagramSocket
- Exchange Active Sync (EAS)
+ Exchange Active Sync (EAS)
HttpClient
JSON
- Mobile broadband
+ Mobile broadband
Radios
RSS reader end-to-end (JavaScript)
- Socket activity trigger stream socket
+ Socket activity trigger stream socket
StreamSocket
Syndication
- USSD protocol
+ USSD protocol
WebSocket
Wi-Fi Direct
- Wi-Fi Direct services
+ Wi-Fi Direct services
Wi-Fi scanning
diff --git a/Samples/Advertising/README.md b/Samples/Advertising/README.md
new file mode 100644
index 0000000000..a9351ff2f5
--- /dev/null
+++ b/Samples/Advertising/README.md
@@ -0,0 +1,65 @@
+
+
+# Advertising sample
+
+This sample shows how to use the Microsoft Advertising SDK (Microsoft.Advertising) to show display ads and interstitial ads using the following methods:
+- Creating an ad control to show display ads using only XAML / HTML markup
+- Creating an ad control to show display ads programatically
+- Creating an ad control to show interstitial video ads programatically
+
+## Prerequisites
+
+This sample requires the [Microsoft Advertising SDK Libraries for XAML or JavaScript](http://go.microsoft.com/fwlink/?LinkID=619694).
+[Download it here](http://go.microsoft.com/fwlink/p/?LinkId=518026).
+It also requires the [internet client capability](https://msdn.microsoft.com/library/windows/apps/mt270968#general-use_capabilities) to be added to the manifest.
+
+When you incorporate this sample into your own app,
+obtain your own ApplicationId and AdUnitId from the Dev Center.
+See [Monetize with Ads](https://msdn.microsoft.com/en-us/library/windows/apps/mt170658.aspx) on MSDN
+for more details.
+
+## Related topics
+
+### Samples
+
+[Store in-app purchase](/Samples/Store)
+
+## Reference
+
+[Microsoft Advertising Client SDK API Reference](https://msdn.microsoft.com/en-US/library/mt313151(v=msads.30).aspx)
+
+### See also
+
+[Getting Started](https://msdn.microsoft.com/en-US/library/mt313197(v=msads.30).aspx)
+
+[Developer Walkthroughs](https://msdn.microsoft.com/en-US/library/mt313121(v=msads.30).aspx)
+
+[Interstitial Ads](https://msdn.microsoft.com/en-US/library/mt313191(v=msads.30).aspx)
+
+## System requirements
+
+**Client:** Windows 10
+
+**Phone:** Windows 10
+
+## Build the sample
+
+1. If you download the samples ZIP, be sure to unzip the entire archive, not just the folder with the sample you want to build.
+2. Start Microsoft Visual Studio 2015 and select **File** \> **Open** \> **Project/Solution**.
+3. Starting in the folder where you unzipped the samples, go to the Samples subfolder, then the subfolder for this specific sample, then the subfolder for your preferred language (C++, C#, or JavaScript). Double-click the Visual Studio�2015 Solution (.sln) file.
+4. Press Ctrl+Shift+B, or select **Build** \> **Build Solution**.
+
+## Run the sample
+
+The next steps depend on whether you just want to deploy the sample or you want to both deploy and run it.
+
+### Deploying the sample
+
+- Select Build > Deploy Solution.
+
+### Deploying and running the sample
+
+- To debug the sample and then run it, press F5 or select Debug > Start Debugging. To run the sample without debugging, press Ctrl+F5 or selectDebug > Start Without Debugging.
diff --git a/Samples/Advertising/cpp/Advertising.sln b/Samples/Advertising/cpp/Advertising.sln
new file mode 100644
index 0000000000..4d5282297c
--- /dev/null
+++ b/Samples/Advertising/cpp/Advertising.sln
@@ -0,0 +1,40 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 14
+VisualStudioVersion = 14.0.23107.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Advertising", "Advertising.vcxproj", "{F710B9FD-4E6B-42D7-A99A-6D48888D48B0}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|ARM = Debug|ARM
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|ARM = Release|ARM
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {F710B9FD-4E6B-42D7-A99A-6D48888D48B0}.Debug|ARM.ActiveCfg = Debug|ARM
+ {F710B9FD-4E6B-42D7-A99A-6D48888D48B0}.Debug|ARM.Build.0 = Debug|ARM
+ {F710B9FD-4E6B-42D7-A99A-6D48888D48B0}.Debug|ARM.Deploy.0 = Debug|ARM
+ {F710B9FD-4E6B-42D7-A99A-6D48888D48B0}.Debug|x64.ActiveCfg = Debug|x64
+ {F710B9FD-4E6B-42D7-A99A-6D48888D48B0}.Debug|x64.Build.0 = Debug|x64
+ {F710B9FD-4E6B-42D7-A99A-6D48888D48B0}.Debug|x64.Deploy.0 = Debug|x64
+ {F710B9FD-4E6B-42D7-A99A-6D48888D48B0}.Debug|x86.ActiveCfg = Debug|Win32
+ {F710B9FD-4E6B-42D7-A99A-6D48888D48B0}.Debug|x86.Build.0 = Debug|Win32
+ {F710B9FD-4E6B-42D7-A99A-6D48888D48B0}.Debug|x86.Deploy.0 = Debug|Win32
+ {F710B9FD-4E6B-42D7-A99A-6D48888D48B0}.Release|ARM.ActiveCfg = Release|ARM
+ {F710B9FD-4E6B-42D7-A99A-6D48888D48B0}.Release|ARM.Build.0 = Release|ARM
+ {F710B9FD-4E6B-42D7-A99A-6D48888D48B0}.Release|ARM.Deploy.0 = Release|ARM
+ {F710B9FD-4E6B-42D7-A99A-6D48888D48B0}.Release|x64.ActiveCfg = Release|x64
+ {F710B9FD-4E6B-42D7-A99A-6D48888D48B0}.Release|x64.Build.0 = Release|x64
+ {F710B9FD-4E6B-42D7-A99A-6D48888D48B0}.Release|x64.Deploy.0 = Release|x64
+ {F710B9FD-4E6B-42D7-A99A-6D48888D48B0}.Release|x86.ActiveCfg = Release|Win32
+ {F710B9FD-4E6B-42D7-A99A-6D48888D48B0}.Release|x86.Build.0 = Release|Win32
+ {F710B9FD-4E6B-42D7-A99A-6D48888D48B0}.Release|x86.Deploy.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/Samples/Advertising/cpp/Advertising.vcxproj b/Samples/Advertising/cpp/Advertising.vcxproj
new file mode 100644
index 0000000000..bc2ff05df2
--- /dev/null
+++ b/Samples/Advertising/cpp/Advertising.vcxproj
@@ -0,0 +1,228 @@
+
+
+
+ {f710b9fd-4e6b-42d7-a99a-6d48888d48b0}
+ SDKTemplate
+ en-US
+ 14.0
+ true
+ Windows Store
+ 10.0
+ 10.0.10240.0
+ 10.0.10240.0
+
+
+
+
+ Debug
+ ARM
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ ARM
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+ Application
+ true
+ v140
+
+
+ Application
+ true
+ v140
+
+
+ Application
+ true
+ v140
+
+
+ Application
+ false
+ true
+ v140
+
+
+ Application
+ false
+ true
+ v140
+
+
+ Application
+ false
+ true
+ v140
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $(VC_IncludePath);$(UniversalCRT_IncludePath);$(WindowsSDK_IncludePath);..\..\..\SharedContent\cpp
+
+
+
+ /bigobj %(AdditionalOptions)
+ 4453;28204
+
+
+
+
+ /bigobj %(AdditionalOptions)
+ 4453;28204
+
+
+
+
+ /bigobj %(AdditionalOptions)
+ 4453;28204
+
+
+
+
+ /bigobj %(AdditionalOptions)
+ 4453;28204
+
+
+
+
+ /bigobj %(AdditionalOptions)
+ 4453;28204
+
+
+
+
+ /bigobj %(AdditionalOptions)
+ 4453;28204
+
+
+
+
+
+ ..\..\..\SharedContent\xaml\App.xaml
+
+
+ ..\..\..\SharedContent\cpp\MainPage.xaml
+
+
+
+ ..\shared\Scenario1_XamlAdControl.xaml
+
+
+ ..\shared\Scenario2_ProgramaticAdControl.xaml
+
+
+ ..\shared\Scenario3_InterstitialAd.xaml
+
+
+
+
+ Designer
+
+
+ Designer
+
+
+
+
+
+ Styles\Styles.xaml
+
+
+
+
+ Designer
+
+
+
+
+ ..\..\..\SharedContent\xaml\App.xaml
+
+
+ ..\..\..\SharedContent\cpp\MainPage.xaml
+
+
+ Create
+ Create
+ Create
+ Create
+ Create
+ Create
+
+
+
+ ..\shared\Scenario1_XamlAdControl.xaml
+
+
+ ..\shared\Scenario2_ProgramaticAdControl.xaml
+
+
+ ..\shared\Scenario3_InterstitialAd.xaml
+
+
+
+
+ Assets\microsoft-sdk.png
+
+
+ Assets\smalltile-sdk.png
+
+
+ Assets\splash-sdk.png
+
+
+ Assets\squaretile-sdk.png
+
+
+ Assets\storelogo-sdk.png
+
+
+ Assets\tile-sdk.png
+
+
+ Assets\windows-sdk.png
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Samples/Advertising/cpp/Advertising.vcxproj.filters b/Samples/Advertising/cpp/Advertising.vcxproj.filters
new file mode 100644
index 0000000000..2e538e7b56
--- /dev/null
+++ b/Samples/Advertising/cpp/Advertising.vcxproj.filters
@@ -0,0 +1,68 @@
+
+
+
+
+ 80bfd669-aa83-4537-9611-027cffe0d8af
+ bmp;fbx;gif;jpg;jpeg;tga;tiff;tif;png
+
+
+ {c6978fb6-bc64-498d-97c8-f5b53997e54e}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Styles
+
+
+
+
+
+
+
+ Assets
+
+
+ Assets
+
+
+ Assets
+
+
+ Assets
+
+
+ Assets
+
+
+ Assets
+
+
+ Assets
+
+
+
\ No newline at end of file
diff --git a/Samples/Advertising/cpp/Package.appxmanifest b/Samples/Advertising/cpp/Package.appxmanifest
new file mode 100644
index 0000000000..452cff1453
--- /dev/null
+++ b/Samples/Advertising/cpp/Package.appxmanifest
@@ -0,0 +1,42 @@
+
+
+
+
+
+ Advertising C++ Sample
+ Microsoft Corporation
+ Assets\StoreLogo-sdk.png
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Samples/Advertising/cpp/SampleConfiguration.cpp b/Samples/Advertising/cpp/SampleConfiguration.cpp
new file mode 100644
index 0000000000..f846ea3f4f
--- /dev/null
+++ b/Samples/Advertising/cpp/SampleConfiguration.cpp
@@ -0,0 +1,23 @@
+//*********************************************************
+//
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the MIT License (MIT).
+// 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.
+//
+//*********************************************************
+
+#include "pch.h"
+#include "MainPage.xaml.h"
+#include "SampleConfiguration.h"
+
+using namespace SDKTemplate;
+
+Platform::Array^ MainPage::scenariosInner = ref new Platform::Array
+{
+ { "Create an ad control in markup", "SDKTemplate.Scenario1_XamlAdControl" },
+ { "Create an ad control programatically", "SDKTemplate.Scenario2_ProgramaticAdControl" },
+ { "Show an interstitial video ad", "SDKTemplate.Scenario3_InterstitialAd" }
+};
diff --git a/Samples/Advertising/cpp/SampleConfiguration.h b/Samples/Advertising/cpp/SampleConfiguration.h
new file mode 100644
index 0000000000..aec3c3d870
--- /dev/null
+++ b/Samples/Advertising/cpp/SampleConfiguration.h
@@ -0,0 +1,47 @@
+//*********************************************************
+//
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the MIT License (MIT).
+// 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.
+//
+//*********************************************************
+
+#pragma once
+#include "pch.h"
+
+namespace SDKTemplate
+{
+ value struct Scenario;
+
+ partial ref class MainPage
+ {
+ internal:
+ static property Platform::String^ FEATURE_NAME
+ {
+ Platform::String^ get()
+ {
+ return "Advertising C++ sample";
+ }
+ }
+
+ static property Platform::Array^ scenarios
+ {
+ Platform::Array^ get()
+ {
+ return scenariosInner;
+ }
+ }
+
+ private:
+ static Platform::Array^ scenariosInner;
+ };
+
+ public value struct Scenario
+ {
+ Platform::String^ Title;
+ Platform::String^ ClassName;
+ };
+}
diff --git a/Samples/Advertising/cpp/Scenario1_XamlAdControl.xaml.cpp b/Samples/Advertising/cpp/Scenario1_XamlAdControl.xaml.cpp
new file mode 100644
index 0000000000..49691b25eb
--- /dev/null
+++ b/Samples/Advertising/cpp/Scenario1_XamlAdControl.xaml.cpp
@@ -0,0 +1,39 @@
+//*********************************************************
+//
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the MIT License (MIT).
+// 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.
+//
+//*********************************************************
+#include "pch.h"
+#include "Scenario1_XamlAdControl.xaml.h"
+
+using namespace SDKTemplate;
+
+using namespace Microsoft::Advertising::WinRT::UI;
+using namespace Platform;
+using namespace Windows::Foundation;
+using namespace Windows::UI::Xaml;
+using namespace Windows::UI::Xaml::Controls;
+
+Scenario1_XamlAdControl::Scenario1_XamlAdControl()
+{
+ InitializeComponent();
+}
+
+// This is an error handler for the ad control.
+void Scenario1_XamlAdControl::OnErrorOccurred(Object^ sender, AdErrorEventArgs^ e)
+{
+ rootPage->NotifyUser("An error occurred. " + e->ErrorCode.ToString() + ": " + e->ErrorMessage, NotifyType::ErrorMessage);
+}
+
+// This is an event handler for the ad control. It's invoked when the ad is refreshed.
+void Scenario1_XamlAdControl::OnAdRefreshed(Object^ sender, RoutedEventArgs^ e)
+{
+ // We increment the ad count so that the message changes at every refresh.
+ adCount++;
+ rootPage->NotifyUser("Advertisement #" + adCount.ToString(), NotifyType::StatusMessage);
+}
\ No newline at end of file
diff --git a/Samples/Advertising/cpp/Scenario1_XamlAdControl.xaml.h b/Samples/Advertising/cpp/Scenario1_XamlAdControl.xaml.h
new file mode 100644
index 0000000000..c861cb04a0
--- /dev/null
+++ b/Samples/Advertising/cpp/Scenario1_XamlAdControl.xaml.h
@@ -0,0 +1,33 @@
+//*********************************************************
+//
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the MIT License (MIT).
+// 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.
+//
+//*********************************************************
+
+#pragma once
+
+#include "Scenario1_XamlAdControl.g.h"
+#include "MainPage.xaml.h"
+
+namespace SDKTemplate
+{
+ [Windows::Foundation::Metadata::WebHostHidden]
+ public ref class Scenario1_XamlAdControl sealed
+ {
+ public:
+ Scenario1_XamlAdControl();
+
+ private:
+ MainPage^ rootPage = MainPage::Current;
+ int adCount = 0;
+
+ void OnErrorOccurred(Platform::Object^ sender, Microsoft::Advertising::WinRT::UI::AdErrorEventArgs^ args);
+ void OnAdRefreshed(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ args);
+
+ }
+}
diff --git a/Samples/Advertising/cpp/Scenario2_ProgramaticAdControl.xaml.cpp b/Samples/Advertising/cpp/Scenario2_ProgramaticAdControl.xaml.cpp
new file mode 100644
index 0000000000..ab3fa725a6
--- /dev/null
+++ b/Samples/Advertising/cpp/Scenario2_ProgramaticAdControl.xaml.cpp
@@ -0,0 +1,67 @@
+//*********************************************************
+//
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the MIT License (MIT).
+// 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.
+//
+//*********************************************************
+
+#include "pch.h"
+#include "Scenario2_ProgramaticAdControl.xaml.h"
+
+using namespace SDKTemplate;
+
+using namespace Microsoft::Advertising::WinRT::UI;
+using namespace Platform;
+using namespace Windows::Foundation;
+using namespace Windows::UI::Xaml;
+using namespace Windows::UI::Xaml::Controls;
+
+Scenario2_ProgramaticAdControl::Scenario2_ProgramaticAdControl()
+{
+ InitializeComponent();
+}
+
+void Scenario2_ProgramaticAdControl::CreateAdControl_Click(Object^ sender, RoutedEventArgs^ e)
+{
+ auto button = safe_cast(sender);
+ button->IsEnabled = false;
+
+ // Programatically create an ad control. This must be done from the UI thread.
+ auto adControl = ref new AdControl();
+
+ // Set the application id and ad unit id
+ // The application id and ad unit id can be obtained from Dev Center.
+ // See "Monetize with Ads" at https ://msdn.microsoft.com/en-us/library/windows/apps/mt170658.aspx
+ adControl->ApplicationId = L"d25517cb-12d4-4699-8bdc-52040c712cab";
+ adControl->AdUnitId = L"10043134";
+
+ // Set the dimensions
+ adControl->Width = 160;
+ adControl->Height = 600;
+
+ // Add event handlers if you want
+ adControl->ErrorOccurred += ref new EventHandler(this, &Scenario2_ProgramaticAdControl::OnErrorOccurred);
+ adControl->AdRefreshed += ref new EventHandler(this, &Scenario2_ProgramaticAdControl::OnAdRefreshed);
+
+ // Add the ad control to the page
+ auto parent = safe_cast(button->Parent);
+ parent->Children->Append(adControl);
+}
+
+// This is an error handler for the ad control.
+void Scenario2_ProgramaticAdControl::OnErrorOccurred(Object^ sender, AdErrorEventArgs^ e)
+{
+ rootPage->NotifyUser("An error occurred. " + e->ErrorCode.ToString() + ": " + e->ErrorMessage, NotifyType::ErrorMessage);
+}
+
+// This is an event handler for the ad control. It's invoked when the ad is refreshed.
+void Scenario2_ProgramaticAdControl::OnAdRefreshed(Object^ sender, RoutedEventArgs^ e)
+{
+ // We increment the ad count so that the message changes at every refresh.
+ adCount++;
+ rootPage->NotifyUser("Advertisement #" + adCount.ToString(), NotifyType::StatusMessage);
+}
diff --git a/Samples/Advertising/cpp/Scenario2_ProgramaticAdControl.xaml.h b/Samples/Advertising/cpp/Scenario2_ProgramaticAdControl.xaml.h
new file mode 100644
index 0000000000..86f695bcdc
--- /dev/null
+++ b/Samples/Advertising/cpp/Scenario2_ProgramaticAdControl.xaml.h
@@ -0,0 +1,33 @@
+//*********************************************************
+//
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the MIT License (MIT).
+// 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.
+//
+//*********************************************************
+
+#pragma once
+
+#include "Scenario2_ProgramaticAdControl.g.h"
+#include "MainPage.xaml.h"
+
+namespace SDKTemplate
+{
+ [Windows::Foundation::Metadata::WebHostHidden]
+ public ref class Scenario2_ProgramaticAdControl sealed
+ {
+ public:
+ Scenario2_ProgramaticAdControl();
+
+ private:
+ MainPage^ rootPage = MainPage::Current;
+ int adCount = 0;
+
+ void CreateAdControl_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
+ void OnErrorOccurred(Platform::Object^ sender, Microsoft::Advertising::WinRT::UI::AdErrorEventArgs^ e);
+ void OnAdRefreshed(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
+ };
+}
diff --git a/Samples/Advertising/cpp/Scenario3_InterstitialAd.xaml.cpp b/Samples/Advertising/cpp/Scenario3_InterstitialAd.xaml.cpp
new file mode 100644
index 0000000000..7c9324c44e
--- /dev/null
+++ b/Samples/Advertising/cpp/Scenario3_InterstitialAd.xaml.cpp
@@ -0,0 +1,70 @@
+//*********************************************************
+//
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the MIT License (MIT).
+// 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.
+//
+//*********************************************************
+
+#include "pch.h"
+#include "Scenario3_InterstitialAd.xaml.h"
+
+using namespace SDKTemplate;
+
+using namespace Microsoft::Advertising::WinRT::UI;
+using namespace Platform;
+using namespace Windows::Foundation;
+using namespace Windows::UI::Xaml;
+using namespace Windows::UI::Xaml::Controls;
+
+Scenario3_InterstitialAd::Scenario3_InterstitialAd() : rootPage(MainPage::Current)
+{
+ InitializeComponent();
+
+ // Instantiate the interstitial ad
+ interstitialAd = ref new InterstitialAd();
+
+ // Attach event handlers
+ interstitialAd->ErrorOccurred += ref new EventHandler(this, &Scenario3_InterstitialAd::OnErrorOccurred);
+ interstitialAd->AdReady += ref new EventHandler(this, &Scenario3_InterstitialAd::OnAdReady);
+ interstitialAd->Cancelled += ref new EventHandler(this, &Scenario3_InterstitialAd::OnAdCancelled);
+ interstitialAd->Completed += ref new EventHandler(this, &Scenario3_InterstitialAd::OnAdCompleted);
+}
+
+void Scenario3_InterstitialAd::RunInterstitialAd(Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
+{
+ // Request an ad. When the ad is ready to show, the AdReady event will fire.
+ // The application id and ad unit are passed in here.
+ // The application id and ad unit id can be obtained from Dev Center.
+ // See "Monetize with Ads" at https://msdn.microsoft.com/en-us/library/windows/apps/mt170658.aspx
+ interstitialAd->RequestAd(AdType::Video, L"d25517cb-12d4-4699-8bdc-52040c712cab", L"11389925");
+ rootPage->NotifyUser("Ad requested", NotifyType::StatusMessage);
+}
+
+// This is an event handler for the interstitial ad. It is triggered when the interstitial ad information has been downloaded and is ready to show.
+void Scenario3_InterstitialAd::OnAdReady(Object^ sender, Object^ e)
+{
+ // The ad is ready to show; show it.
+ interstitialAd->Show();
+}
+
+// This is an event handler for the interstitial ad. It is triggered when the interstitial ad is cancelled.
+void Scenario3_InterstitialAd::OnAdCancelled(Object^ sender, Object^ e)
+{
+ rootPage->NotifyUser("Ad cancelled", NotifyType::StatusMessage);
+}
+
+// This is an event handler for the interstitial ad. It is triggered when the interstitial ad has completed playback.
+void Scenario3_InterstitialAd::OnAdCompleted(Object^ sender, Object^ e)
+{
+ rootPage->NotifyUser("Ad completed", NotifyType::StatusMessage);
+}
+
+// This is an error handler for the interstitial ad.
+void Scenario3_InterstitialAd::OnErrorOccurred(Object^ sender, AdErrorEventArgs^ e)
+{
+ rootPage->NotifyUser("An error occurred. " + e->ErrorCode.ToString() + ": " + e->ErrorMessage, NotifyType::ErrorMessage);
+}
\ No newline at end of file
diff --git a/Samples/Advertising/cpp/Scenario3_InterstitialAd.xaml.h b/Samples/Advertising/cpp/Scenario3_InterstitialAd.xaml.h
new file mode 100644
index 0000000000..0535ad6758
--- /dev/null
+++ b/Samples/Advertising/cpp/Scenario3_InterstitialAd.xaml.h
@@ -0,0 +1,35 @@
+//*********************************************************
+//
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the MIT License (MIT).
+// 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.
+//
+//*********************************************************
+
+#pragma once
+
+#include "Scenario3_InterstitialAd.g.h"
+#include "MainPage.xaml.h"
+
+namespace SDKTemplate
+{
+ [Windows::Foundation::Metadata::WebHostHidden]
+ public ref class Scenario3_InterstitialAd sealed
+ {
+ public:
+ Scenario3_InterstitialAd();
+
+ private:
+ MainPage^ rootPage = MainPage::Current;
+ Microsoft::Advertising::WinRT::UI::InterstitialAd^ interstitialAd;
+
+ void RunInterstitialAd(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
+ void OnAdReady(Platform::Object^ sender, Platform::Object^ args);
+ void OnAdCancelled(Platform::Object^ sender, Platform::Object^ args);
+ void OnAdCompleted(Platform::Object^ sender, Platform::Object^ args);
+ void OnErrorOccurred(Platform::Object^ sender, Microsoft::Advertising::WinRT::UI::AdErrorEventArgs^ args);
+ };
+}
diff --git a/Samples/Advertising/cpp/pch.cpp b/Samples/Advertising/cpp/pch.cpp
new file mode 100644
index 0000000000..ade821753a
--- /dev/null
+++ b/Samples/Advertising/cpp/pch.cpp
@@ -0,0 +1,5 @@
+//
+// Include the standard header and generate the precompiled header.
+//
+
+#include "pch.h"
diff --git a/Samples/Advertising/cpp/pch.h b/Samples/Advertising/cpp/pch.h
new file mode 100644
index 0000000000..1dcc72eba4
--- /dev/null
+++ b/Samples/Advertising/cpp/pch.h
@@ -0,0 +1,10 @@
+//
+// Header for standard system include files.
+//
+
+#pragma once
+
+#include
+#include
+
+#include "App.xaml.h"
diff --git a/Samples/Advertising/cs/Advertising.csproj b/Samples/Advertising/cs/Advertising.csproj
new file mode 100644
index 0000000000..c379520f2b
--- /dev/null
+++ b/Samples/Advertising/cs/Advertising.csproj
@@ -0,0 +1,198 @@
+
+
+
+
+ Debug
+ x86
+ {DC30CE66-DAEE-4CCF-BD02-8837FE918B6F}
+ AppContainerExe
+ Properties
+ SDKTemplate
+ Advertising
+ en-US
+ UAP
+ 10.0.10240.0
+ 10.0.10240.0
+ 14
+ true
+ 512
+ {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+
+
+ true
+ bin\ARM\Debug\
+ DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
+ ;2008
+ full
+ ARM
+ false
+ prompt
+ true
+
+
+ bin\ARM\Release\
+ TRACE;NETFX_CORE;WINDOWS_UWP
+ true
+ ;2008
+ pdbonly
+ ARM
+ false
+ prompt
+ true
+ true
+
+
+ true
+ bin\x64\Debug\
+ DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
+ ;2008
+ full
+ x64
+ false
+ prompt
+ true
+
+
+ bin\x64\Release\
+ TRACE;NETFX_CORE;WINDOWS_UWP
+ true
+ ;2008
+ pdbonly
+ x64
+ false
+ prompt
+ true
+ true
+
+
+ true
+ bin\x86\Debug\
+ DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
+ ;2008
+ full
+ x86
+ false
+ prompt
+ true
+
+
+ bin\x86\Release\
+ TRACE;NETFX_CORE;WINDOWS_UWP
+ true
+ ;2008
+ pdbonly
+ x86
+ false
+ prompt
+ true
+ true
+
+
+
+
+
+
+ App.xaml.cs
+ App.xaml
+
+
+ MainPage.xaml.cs
+ MainPage.xaml
+
+
+ Properties\AssemblyInfo.cs
+
+
+
+ Scenario1_XamlAdControl.xaml
+
+
+ Scenario2_ProgramaticAdControl.xaml
+
+
+ Scenario3_InterstitialAd.xaml
+
+
+
+
+ Designer
+
+
+
+
+ App.xaml
+ MSBuild:Compile
+ Designer
+
+
+ MainPage.xaml
+ MSBuild:Compile
+ Designer
+
+
+ Scenario1_XamlAdControl.xaml
+ MSBuild:Compile
+ Designer
+
+
+ Scenario2_ProgramaticAdControl.xaml
+ MSBuild:Compile
+ Designer
+
+
+ Scenario3_InterstitialAd.xaml
+ MSBuild:Compile
+ Designer
+
+
+ Styles\Styles.xaml
+ MSBuild:Compile
+ Designer
+
+
+
+
+ Properties\Default.rd.xml
+
+
+ Assets\microsoft-sdk.png
+
+
+ Assets\smallTile-sdk.png
+
+
+ Assets\splash-sdk.png
+
+
+ Assets\squareTile-sdk.png
+
+
+ Assets\storeLogo-sdk.png
+
+
+ Assets\tile-sdk.png
+
+
+ Assets\windows-sdk.png
+
+
+
+
+ Microsoft Advertising SDK for XAML
+
+
+ Visual C++ 2015 Runtime for Universal Windows Platform Apps
+
+
+
+ 14.0
+
+
+
+
\ No newline at end of file
diff --git a/Samples/Advertising/cs/Advertising.sln b/Samples/Advertising/cs/Advertising.sln
new file mode 100644
index 0000000000..106a851717
--- /dev/null
+++ b/Samples/Advertising/cs/Advertising.sln
@@ -0,0 +1,40 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 14
+VisualStudioVersion = 14.0.23107.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Advertising", "Advertising.csproj", "{DC30CE66-DAEE-4CCF-BD02-8837FE918B6F}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|ARM = Debug|ARM
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|ARM = Release|ARM
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {DC30CE66-DAEE-4CCF-BD02-8837FE918B6F}.Debug|ARM.ActiveCfg = Debug|ARM
+ {DC30CE66-DAEE-4CCF-BD02-8837FE918B6F}.Debug|ARM.Build.0 = Debug|ARM
+ {DC30CE66-DAEE-4CCF-BD02-8837FE918B6F}.Debug|ARM.Deploy.0 = Debug|ARM
+ {DC30CE66-DAEE-4CCF-BD02-8837FE918B6F}.Debug|x64.ActiveCfg = Debug|x64
+ {DC30CE66-DAEE-4CCF-BD02-8837FE918B6F}.Debug|x64.Build.0 = Debug|x64
+ {DC30CE66-DAEE-4CCF-BD02-8837FE918B6F}.Debug|x64.Deploy.0 = Debug|x64
+ {DC30CE66-DAEE-4CCF-BD02-8837FE918B6F}.Debug|x86.ActiveCfg = Debug|x86
+ {DC30CE66-DAEE-4CCF-BD02-8837FE918B6F}.Debug|x86.Build.0 = Debug|x86
+ {DC30CE66-DAEE-4CCF-BD02-8837FE918B6F}.Debug|x86.Deploy.0 = Debug|x86
+ {DC30CE66-DAEE-4CCF-BD02-8837FE918B6F}.Release|ARM.ActiveCfg = Release|ARM
+ {DC30CE66-DAEE-4CCF-BD02-8837FE918B6F}.Release|ARM.Build.0 = Release|ARM
+ {DC30CE66-DAEE-4CCF-BD02-8837FE918B6F}.Release|ARM.Deploy.0 = Release|ARM
+ {DC30CE66-DAEE-4CCF-BD02-8837FE918B6F}.Release|x64.ActiveCfg = Release|x64
+ {DC30CE66-DAEE-4CCF-BD02-8837FE918B6F}.Release|x64.Build.0 = Release|x64
+ {DC30CE66-DAEE-4CCF-BD02-8837FE918B6F}.Release|x64.Deploy.0 = Release|x64
+ {DC30CE66-DAEE-4CCF-BD02-8837FE918B6F}.Release|x86.ActiveCfg = Release|x86
+ {DC30CE66-DAEE-4CCF-BD02-8837FE918B6F}.Release|x86.Build.0 = Release|x86
+ {DC30CE66-DAEE-4CCF-BD02-8837FE918B6F}.Release|x86.Deploy.0 = Release|x86
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/Samples/Advertising/cs/Package.appxmanifest b/Samples/Advertising/cs/Package.appxmanifest
new file mode 100644
index 0000000000..87f0cebf5e
--- /dev/null
+++ b/Samples/Advertising/cs/Package.appxmanifest
@@ -0,0 +1,42 @@
+
+
+
+
+
+ Advertising C# Sample
+ Microsoft Corporation
+ Assets\StoreLogo-sdk.png
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Samples/Advertising/cs/SampleConfiguration.cs b/Samples/Advertising/cs/SampleConfiguration.cs
new file mode 100644
index 0000000000..bc27e04bbf
--- /dev/null
+++ b/Samples/Advertising/cs/SampleConfiguration.cs
@@ -0,0 +1,35 @@
+//*********************************************************
+//
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the MIT License (MIT).
+// 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 System;
+using System.Collections.Generic;
+using Windows.UI.Xaml.Controls;
+
+namespace SDKTemplate
+{
+ public partial class MainPage : Page
+ {
+ public const string FEATURE_NAME = "Advertising C# Sample";
+
+ List scenarios = new List
+ {
+ new Scenario() { Title="Create an ad control in markup", ClassType=typeof(Scenario1_XamlAdControl)},
+ new Scenario() { Title="Create an ad control programatically", ClassType=typeof(Scenario2_ProgramaticAdControl)},
+ new Scenario() { Title="Show an interstitial video ad", ClassType=typeof(Scenario3_InterstitialAd)}
+ };
+ }
+
+ public class Scenario
+ {
+ public string Title { get; set; }
+ public Type ClassType { get; set; }
+ }
+}
diff --git a/Samples/Advertising/cs/Scenario1_XamlAdControl.xaml.cs b/Samples/Advertising/cs/Scenario1_XamlAdControl.xaml.cs
new file mode 100644
index 0000000000..5dd46e8653
--- /dev/null
+++ b/Samples/Advertising/cs/Scenario1_XamlAdControl.xaml.cs
@@ -0,0 +1,42 @@
+//*********************************************************
+//
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the MIT License (MIT).
+// 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 Microsoft.Advertising.WinRT.UI;
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Controls;
+
+namespace SDKTemplate
+{
+ public sealed partial class Scenario1_XamlAdControl : Page
+ {
+ private MainPage rootPage = MainPage.Current;
+ private int adCount = 0;
+
+ public Scenario1_XamlAdControl()
+ {
+ this.InitializeComponent();
+ }
+
+ // This is an error handler for the interstitial ad.
+ private void OnErrorOccurred(object sender, AdErrorEventArgs e)
+ {
+ rootPage.NotifyUser($"An error occurred. {e.ErrorCode}: {e.ErrorMessage}", NotifyType.ErrorMessage);
+ }
+
+ // This is an event handler for the ad control. It's invoked when the ad is refreshed.
+ private void OnAdRefreshed(object sender, RoutedEventArgs e)
+ {
+ // We increment the ad count so that the message changes at every refresh.
+ adCount++;
+ rootPage.NotifyUser($"Advertisement #{adCount}", NotifyType.StatusMessage);
+ }
+ }
+}
diff --git a/Samples/Advertising/cs/Scenario2_ProgramaticAdControl.xaml.cs b/Samples/Advertising/cs/Scenario2_ProgramaticAdControl.xaml.cs
new file mode 100644
index 0000000000..00f2cb0a26
--- /dev/null
+++ b/Samples/Advertising/cs/Scenario2_ProgramaticAdControl.xaml.cs
@@ -0,0 +1,69 @@
+//*********************************************************
+//
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the MIT License (MIT).
+// 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 Microsoft.Advertising.WinRT.UI;
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Controls;
+
+namespace SDKTemplate
+{
+ public sealed partial class Scenario2_ProgramaticAdControl : Page
+ {
+ MainPage rootPage = MainPage.Current;
+ int adCount = 0;
+
+ public Scenario2_ProgramaticAdControl()
+ {
+ this.InitializeComponent();
+ }
+
+ private void CreateAdControl_Click(object sender, RoutedEventArgs e)
+ {
+ var button = (Button)sender;
+ button.IsEnabled = false;
+
+ // Programatically create an ad control. This must be done from the UI thread.
+ var adControl = new AdControl();
+
+ // Set the application id and ad unit id
+ // The application id and ad unit id can be obtained from Dev Center.
+ // See "Monetize with Ads" at https://msdn.microsoft.com/en-us/library/windows/apps/mt170658.aspx
+ adControl.ApplicationId = "d25517cb-12d4-4699-8bdc-52040c712cab";
+ adControl.AdUnitId = "10043134";
+
+ // Set the dimensions
+ adControl.Width = 160;
+ adControl.Height = 600;
+
+ // Add event handlers if you want
+ adControl.ErrorOccurred += OnErrorOccurred;
+ adControl.AdRefreshed += OnAdRefreshed;
+
+ // Add the ad control to the page.
+ var parent = (Panel)button.Parent;
+ parent.Children.Add(adControl);
+ }
+
+ // This is an error handler for the interstitial ad.
+ private void OnErrorOccurred(object sender, AdErrorEventArgs e)
+ {
+ rootPage.NotifyUser($"An error occurred. {e.ErrorCode}: {e.ErrorMessage}", NotifyType.ErrorMessage);
+ }
+
+ // This is an event handler for the ad control. It's invoked when the ad is refreshed.
+ private void OnAdRefreshed(object sender, RoutedEventArgs e)
+ {
+ // We increment the ad count so that the message changes at every refresh.
+ adCount++;
+ rootPage.NotifyUser($"Advertisement #{adCount}", NotifyType.StatusMessage);
+ }
+ }
+}
diff --git a/Samples/Advertising/cs/Scenario3_InterstitialAd.xaml.cs b/Samples/Advertising/cs/Scenario3_InterstitialAd.xaml.cs
new file mode 100644
index 0000000000..25704ff2b9
--- /dev/null
+++ b/Samples/Advertising/cs/Scenario3_InterstitialAd.xaml.cs
@@ -0,0 +1,72 @@
+//*********************************************************
+//
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the MIT License (MIT).
+// 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 Microsoft.Advertising.WinRT.UI;
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Controls;
+
+namespace SDKTemplate
+{
+ public sealed partial class Scenario3_InterstitialAd : Page
+ {
+ private MainPage rootPage = MainPage.Current;
+ private InterstitialAd interstitialAd;
+
+ public Scenario3_InterstitialAd()
+ {
+ this.InitializeComponent();
+
+ // Instantiate the interstitial video ad
+ interstitialAd = new InterstitialAd();
+
+ // Attach event handlers
+ interstitialAd.ErrorOccurred += OnAdError;
+ interstitialAd.AdReady += OnAdReady;
+ interstitialAd.Cancelled += OnAdCancelled;
+ interstitialAd.Completed += OnAdCompleted;
+ }
+
+ private void RunInterstitialAd(object sender, RoutedEventArgs e)
+ {
+ // Request an ad. When the ad is ready to show, the AdReady event will fire.
+ // The application id and ad unit id are passed in here.
+ // The application id and ad unit id can be obtained from Dev Center.
+ // See "Monetize with Ads" at https://msdn.microsoft.com/en-us/library/windows/apps/mt170658.aspx
+ interstitialAd.RequestAd(AdType.Video, "d25517cb-12d4-4699-8bdc-52040c712cab", "11389925");
+ rootPage.NotifyUser("Ad requested", NotifyType.StatusMessage);
+ }
+
+ // This is an event handler for the interstitial ad. It is triggered when the interstitial ad is ready to play.
+ private void OnAdReady(object sender, object e)
+ {
+ // The ad is ready to show; show it.
+ interstitialAd.Show();
+ }
+
+ // This is an event handler for the interstitial ad. It is triggered when the interstitial ad is cancelled.
+ private void OnAdCancelled(object sender, object e)
+ {
+ rootPage.NotifyUser("Ad cancelled", NotifyType.StatusMessage);
+ }
+
+ // This is an event handler for the interstitial ad. It is triggered when the interstitial ad has completed playback.
+ private void OnAdCompleted(object sender, object e)
+ {
+ rootPage.NotifyUser("Ad completed", NotifyType.StatusMessage);
+ }
+
+ // This is an error handler for the interstitial ad.
+ private void OnAdError(object sender, AdErrorEventArgs e)
+ {
+ rootPage.NotifyUser($"An error occurred. {e.ErrorCode}: {e.ErrorMessage}", NotifyType.ErrorMessage);
+ }
+ }
+}
diff --git a/Samples/Advertising/cs/project.json b/Samples/Advertising/cs/project.json
new file mode 100644
index 0000000000..c594939270
--- /dev/null
+++ b/Samples/Advertising/cs/project.json
@@ -0,0 +1,16 @@
+{
+ "dependencies": {
+ "Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0"
+ },
+ "frameworks": {
+ "uap10.0": {}
+ },
+ "runtimes": {
+ "win10-arm": {},
+ "win10-arm-aot": {},
+ "win10-x86": {},
+ "win10-x86-aot": {},
+ "win10-x64": {},
+ "win10-x64-aot": {}
+ }
+}
\ No newline at end of file
diff --git a/Samples/Advertising/js/Advertising.jsproj b/Samples/Advertising/js/Advertising.jsproj
new file mode 100644
index 0000000000..e228202518
--- /dev/null
+++ b/Samples/Advertising/js/Advertising.jsproj
@@ -0,0 +1,147 @@
+
+
+
+
+ Debug
+ AnyCPU
+
+
+ Debug
+ ARM
+
+
+ Debug
+ x64
+
+
+ Debug
+ x86
+
+
+ Release
+ AnyCPU
+
+
+ Release
+ ARM
+
+
+ Release
+ x64
+
+
+ Release
+ x86
+
+
+
+ c2adb9af-edb3-4e57-8056-9d0531d4a6b2
+
+
+
+ 14.0
+
+
+
+
+ UAP
+ 10.0.10240.0
+ 10.0.10240.0
+ $(VersionNumberMajor).$(VersionNumberMinor)
+ en-US
+
+
+
+ Designer
+
+
+
+
+
+
+
+
+
+ default.html
+
+
+ images\microsoft-sdk.png
+
+
+ images\smallTile-sdk.png
+
+
+ images\splash-sdk.png
+
+
+ images\storeLogo-sdk.png
+
+
+ images\tile-sdk.png
+
+
+ images\windows-sdk.png
+
+
+ js\default.js
+
+
+ css\default.css
+
+
+ Microsoft.WinJS.4.0\css\ui-dark.css
+
+
+ Microsoft.WinJS.4.0\css\ui-light.css
+
+
+ Microsoft.WinJS.4.0\js\en-US\ui.strings.js
+
+
+ Microsoft.WinJS.4.0\js\WinJS.intellisense-setup.js
+
+
+ Microsoft.WinJS.4.0\js\WinJS.intellisense.js
+
+
+ Microsoft.WinJS.4.0\fonts\Symbols.ttf
+
+
+ Microsoft.WinJS.4.0\js\base.js
+
+
+ Microsoft.WinJS.4.0\js\ui.js
+
+
+ sample-utils\footer.html
+
+
+ sample-utils\header.html
+
+
+ sample-utils\sample-utils.js
+
+
+ sample-utils\scenario-select.css
+
+
+ sample-utils\scenario-select.html
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Samples/Advertising/js/Advertising.sln b/Samples/Advertising/js/Advertising.sln
new file mode 100644
index 0000000000..0e905b0771
--- /dev/null
+++ b/Samples/Advertising/js/Advertising.sln
@@ -0,0 +1,48 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 14
+VisualStudioVersion = 14.0.23107.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{262852C6-CD72-467D-83FE-5EEB1973A190}") = "Advertising", "Advertising.jsproj", "{C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Debug|ARM = Debug|ARM
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|Any CPU = Release|Any CPU
+ Release|ARM = Release|ARM
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
+ {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Debug|ARM.ActiveCfg = Debug|ARM
+ {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Debug|ARM.Build.0 = Debug|ARM
+ {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Debug|ARM.Deploy.0 = Debug|ARM
+ {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Debug|x64.ActiveCfg = Debug|x64
+ {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Debug|x64.Build.0 = Debug|x64
+ {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Debug|x64.Deploy.0 = Debug|x64
+ {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Debug|x86.ActiveCfg = Debug|x86
+ {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Debug|x86.Build.0 = Debug|x86
+ {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Debug|x86.Deploy.0 = Debug|x86
+ {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Release|Any CPU.Build.0 = Release|Any CPU
+ {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Release|Any CPU.Deploy.0 = Release|Any CPU
+ {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Release|ARM.ActiveCfg = Release|ARM
+ {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Release|ARM.Build.0 = Release|ARM
+ {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Release|ARM.Deploy.0 = Release|ARM
+ {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Release|x64.ActiveCfg = Release|x64
+ {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Release|x64.Build.0 = Release|x64
+ {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Release|x64.Deploy.0 = Release|x64
+ {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Release|x86.ActiveCfg = Release|x86
+ {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Release|x86.Build.0 = Release|x86
+ {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Release|x86.Deploy.0 = Release|x86
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/Samples/Advertising/js/Microsoft.WinJS.4.0/css/placeholder.txt b/Samples/Advertising/js/Microsoft.WinJS.4.0/css/placeholder.txt
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/Samples/Advertising/js/Microsoft.WinJS.4.0/fonts/placeholder.txt b/Samples/Advertising/js/Microsoft.WinJS.4.0/fonts/placeholder.txt
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/Samples/Advertising/js/Microsoft.WinJS.4.0/js/en-US/placeholder.txt b/Samples/Advertising/js/Microsoft.WinJS.4.0/js/en-US/placeholder.txt
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/Samples/Advertising/js/css/placeholder.txt b/Samples/Advertising/js/css/placeholder.txt
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/Samples/Advertising/js/html/scenario1.html b/Samples/Advertising/js/html/scenario1.html
new file mode 100644
index 0000000000..220a7506de
--- /dev/null
+++ b/Samples/Advertising/js/html/scenario1.html
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Create an ad control in markup
+
+
+
+
+
+
diff --git a/Samples/Advertising/js/html/scenario2.html b/Samples/Advertising/js/html/scenario2.html
new file mode 100644
index 0000000000..0b96b31acf
--- /dev/null
+++ b/Samples/Advertising/js/html/scenario2.html
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Create an ad control programatically
+
+
+ Create ad control
+
+
+
+
+
+
diff --git a/Samples/Advertising/js/html/scenario3.html b/Samples/Advertising/js/html/scenario3.html
new file mode 100644
index 0000000000..0c7cd03fe8
--- /dev/null
+++ b/Samples/Advertising/js/html/scenario3.html
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Show an interstitial video ad
+
+
+ Show ad
+
+
+
diff --git a/Samples/Advertising/js/images/windows-sdk.png b/Samples/Advertising/js/images/windows-sdk.png
new file mode 100644
index 0000000000..67268021df
Binary files /dev/null and b/Samples/Advertising/js/images/windows-sdk.png differ
diff --git a/Samples/Advertising/js/js/sample-configuration.js b/Samples/Advertising/js/js/sample-configuration.js
new file mode 100644
index 0000000000..0d565c1d9d
--- /dev/null
+++ b/Samples/Advertising/js/js/sample-configuration.js
@@ -0,0 +1,18 @@
+//// Copyright (c) Microsoft Corporation. All rights reserved
+
+(function () {
+ "use strict";
+
+ var sampleTitle = "Advertising JS sample";
+
+ var scenarios = [
+ { url: "/html/scenario1.html", title: "Create an ad control in markup" },
+ { url: "/html/scenario2.html", title: "Create an ad control programatically" },
+ { url: "/html/scenario3.html", title: "Show an interstitial video ad" }
+ ];
+
+ WinJS.Namespace.define("SdkSample", {
+ sampleTitle: sampleTitle,
+ scenarios: new WinJS.Binding.List(scenarios)
+ });
+})();
\ No newline at end of file
diff --git a/Samples/Advertising/js/js/scenario1.js b/Samples/Advertising/js/js/scenario1.js
new file mode 100644
index 0000000000..3965c06784
--- /dev/null
+++ b/Samples/Advertising/js/js/scenario1.js
@@ -0,0 +1,26 @@
+//// Copyright (c) Microsoft Corporation. All rights reserved
+
+(function () {
+ "use strict";
+ var adCount = 0;
+
+ var page = WinJS.UI.Pages.define("/html/scenario1.html", {
+ ready: function (element, options) {
+ var adControl = document.getElementById("adContainer").winControl;
+ adControl.onErrorOccurred = errorHandler;
+ adControl.onAdRefreshed = refreshHandler;
+ }
+ });
+
+ // This is an error event handler for the ad control.
+ function errorHandler(adControl, e) {
+ WinJS.log && WinJS.log("An error occurred. " + e.errorCode + ": " + e.errorMessage, "samples", "error");
+ }
+
+ // This is an event handler for the ad control. It is called when the ad is refreshed with a new ad.
+ function refreshHandler(adControl) {
+ // We increment the ad count so that the message changes at every refresh.
+ adCount++;
+ WinJS.log && WinJS.log("Advertisement #" + adCount, "samples", "status");
+ }
+})();
diff --git a/Samples/Advertising/js/js/scenario2.js b/Samples/Advertising/js/js/scenario2.js
new file mode 100644
index 0000000000..d773ee8868
--- /dev/null
+++ b/Samples/Advertising/js/js/scenario2.js
@@ -0,0 +1,44 @@
+//// Copyright (c) Microsoft Corporation. All rights reserved
+
+(function () {
+ "use strict";
+ var adCount = 0;
+ var adContainer;
+
+ var page = WinJS.UI.Pages.define("/html/scenario2.html", {
+ ready: function (element, options) {
+ adContainer = document.getElementById("adContainer");
+ document.getElementById("createAdControlButton").addEventListener("click", createAdControl);
+ }
+ });
+
+ function createAdControl(e) {
+ e.srcElement.disabled = true;
+
+ // Set the ad container's size and position.
+ adContainer.style.width = '160px';
+ adContainer.style.height = '600px';
+
+ // Create the ad control and attach event handlers.
+ // The applicationId and adUnitId can be obtained from Dev Center.
+ // See "Monetize with Ads" at https://msdn.microsoft.com/en-us/library/windows/apps/mt170658.aspx
+ var ad = new MicrosoftNSJS.Advertising.AdControl(adContainer, {
+ applicationId: 'd25517cb-12d4-4699-8bdc-52040c712cab',
+ adUnitId: '10043134',
+ onErrorOccurred: errorHandler,
+ onAdRefreshed: refreshHandler
+ });
+ }
+
+ // This is an error event handler for the ad control.
+ function errorHandler(adControl, e) {
+ WinJS.log && WinJS.log("An error occurred. " + e.errorCode + ": " + e.errorMessage, "samples", "error");
+ }
+
+ // This is an event handler for the ad control. It is called when the ad is refreshed with a new ad.
+ function refreshHandler(adControl) {
+ // We increment the ad count so that the message changes at every refresh.
+ adCount++;
+ WinJS.log && WinJS.log("Advertisement #" + adCount, "samples", "status");
+ }
+})();
diff --git a/Samples/Advertising/js/js/scenario3.js b/Samples/Advertising/js/js/scenario3.js
new file mode 100644
index 0000000000..3bb2a2f368
--- /dev/null
+++ b/Samples/Advertising/js/js/scenario3.js
@@ -0,0 +1,54 @@
+//// Copyright (c) Microsoft Corporation. All rights reserved
+
+(function () {
+ "use strict";
+ var interstitialAd = null;
+
+ var page = WinJS.UI.Pages.define("/html/scenario3.html", {
+ ready: function (element, options) {
+ // Instantiate the ad
+ interstitialAd = new MicrosoftNSJS.Advertising.InterstitialAd();
+
+ // Attach the event handlers
+ interstitialAd.onAdReady = adReadyHandler;
+ interstitialAd.onErrorOccurredHandler = adErrorHandler;
+ interstitialAd.onCancelled = adCancelledHandler;
+ interstitialAd.onCompleted = adCompletedHandler;
+
+ document.getElementById("runInterstitialAdButton").addEventListener("click", requestAdHandler);
+ }
+ });
+
+ function requestAdHandler(e) {
+ // Request the ad.
+ // The application id and ad unit id are passed in here.
+ // The applicationId and adUnitId can be obtained from Dev Center.
+ // See "Monetize with Ads" at https://msdn.microsoft.com/en-us/library/windows/apps/mt170658.aspx
+ interstitialAd.requestAd(MicrosoftNSJS.Advertising.InterstitialAdType.video, "d25517cb-12d4-4699-8bdc-52040c712cab", "11389925");
+ WinJS.log && WinJS.log("Ad requested", "samples", "status");
+ }
+
+ // This is an event handler for the interstitial ad. It is triggered when the interstitial ad information has been downloaded and is ready to show.
+ function adReadyHandler(adControl) {
+ // The ad is ready, show it
+ // In some cases you might choose to request the ad in advance and
+ // show it at the time of your choosing, rather than calling show()
+ // in the adReady event handler. This will reduce the user's wait time for the ad.
+ interstitialAd.show();
+ }
+
+ // This is an event handler for the interstitial ad. It is triggered when the interstitial ad has been cancelled.
+ function adCancelledHandler(adControl) {
+ WinJS.log && WinJS.log("Ad cancelled", "samples", "status");
+ }
+
+ // This is an event handler for the interstitial ad. It is triggered when the interstitial ad playback has completed.
+ function adCompletedHandler(adControl) {
+ WinJS.log && WinJS.log("Ad completed", "samples", "status");
+ }
+
+ // This is an error handler for the interstitial ad.
+ function adErrorHandler(adControl, e) {
+ WinJS.log && WinJS.log("An error occurred. " + e.errorCode + ": " + e.errorMessage, "samples", "error");
+ }
+})();
diff --git a/Samples/Advertising/js/package.appxmanifest b/Samples/Advertising/js/package.appxmanifest
new file mode 100644
index 0000000000..1eedccf71c
--- /dev/null
+++ b/Samples/Advertising/js/package.appxmanifest
@@ -0,0 +1,42 @@
+
+
+
+
+
+ Advertising JS Sample
+ Microsoft Corporation
+ images\storelogo-sdk.png
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Samples/Advertising/js/sample-utils/placeholder.txt b/Samples/Advertising/js/sample-utils/placeholder.txt
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/Samples/Advertising/shared/Scenario1_XamlAdControl.xaml b/Samples/Advertising/shared/Scenario1_XamlAdControl.xaml
new file mode 100644
index 0000000000..b5eb8820e8
--- /dev/null
+++ b/Samples/Advertising/shared/Scenario1_XamlAdControl.xaml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+ Create an ad control in markup
+
+
+
+
+
+
diff --git a/Samples/Advertising/shared/Scenario2_ProgramaticAdControl.xaml b/Samples/Advertising/shared/Scenario2_ProgramaticAdControl.xaml
new file mode 100644
index 0000000000..c87c11084b
--- /dev/null
+++ b/Samples/Advertising/shared/Scenario2_ProgramaticAdControl.xaml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+ Create an ad control programatically
+
+
+
+
diff --git a/Samples/Advertising/shared/Scenario3_InterstitialAd.xaml b/Samples/Advertising/shared/Scenario3_InterstitialAd.xaml
new file mode 100644
index 0000000000..7e64ea646a
--- /dev/null
+++ b/Samples/Advertising/shared/Scenario3_InterstitialAd.xaml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+ Show an interstitial video ad
+
+
+
+
diff --git a/Samples/CameraResolution/cs/Scenario1_PreviewSettings.xaml.cs b/Samples/CameraResolution/cs/Scenario1_PreviewSettings.xaml.cs
index 2210308168..021261febf 100644
--- a/Samples/CameraResolution/cs/Scenario1_PreviewSettings.xaml.cs
+++ b/Samples/CameraResolution/cs/Scenario1_PreviewSettings.xaml.cs
@@ -89,7 +89,7 @@ private async void ComboBoxSettings_Changed(object sender, RoutedEventArgs e)
private void PopulateSettingsComboBox()
{
// Query all properties of the device
- IEnumerable allProperties = _previewer.MediaCapture.VideoDeviceController.GetAvailableMediaStreamProperties(MediaStreamType.VideoRecord).Select(x => new StreamResolution(x));
+ IEnumerable allProperties = _previewer.MediaCapture.VideoDeviceController.GetAvailableMediaStreamProperties(MediaStreamType.VideoPreview).Select(x => new StreamResolution(x));
// Order them by resolution then frame rate
allProperties = allProperties.OrderByDescending(x => x.Height * x.Width).ThenByDescending(x => x.FrameRate);
diff --git a/Samples/Nfc/Nfc/CardReader.xaml.cs b/Samples/Nfc/Nfc/CardReader.xaml.cs
index 01133ad9eb..6a576b985a 100644
--- a/Samples/Nfc/Nfc/CardReader.xaml.cs
+++ b/Samples/Nfc/Nfc/CardReader.xaml.cs
@@ -110,108 +110,107 @@ private async Task HandleCard(SmartCard card)
MainPage.Current.NotifyUser(String.Empty, NotifyType.StatusMessage, true);
// Connect to the card
- var connection = await card.ConnectAsync();
-
- // Try to identify what type of card it was
- IccDetection cardIdentification = new IccDetection(card, connection);
- await cardIdentification.DetectCardTypeAync();
- LogMessage("Connected to card\r\nPC/SC device class: " + cardIdentification.PcscDeviceClass.ToString());
- LogMessage("Card name: " + cardIdentification.PcscCardName.ToString());
- LogMessage("ATR: " + BitConverter.ToString(cardIdentification.Atr));
-
- if ((cardIdentification.PcscDeviceClass == Pcsc.Common.DeviceClass.StorageClass) &&
- (cardIdentification.PcscCardName == Pcsc.CardName.MifareUltralightC
- || cardIdentification.PcscCardName == Pcsc.CardName.MifareUltralight
- || cardIdentification.PcscCardName == Pcsc.CardName.MifareUltralightEV1))
+ using (SmartCardConnection connection = await card.ConnectAsync())
{
- // Handle MIFARE Ultralight
- MifareUltralight.AccessHandler mifareULAccess = new MifareUltralight.AccessHandler(connection);
-
- // Each read should get us 16 bytes/4 blocks, so doing
- // 4 reads will get us all 64 bytes/16 blocks on the card
- for (byte i = 0; i < 4; i++)
+ // Try to identify what type of card it was
+ IccDetection cardIdentification = new IccDetection(card, connection);
+ await cardIdentification.DetectCardTypeAync();
+ LogMessage("Connected to card\r\nPC/SC device class: " + cardIdentification.PcscDeviceClass.ToString());
+ LogMessage("Card name: " + cardIdentification.PcscCardName.ToString());
+ LogMessage("ATR: " + BitConverter.ToString(cardIdentification.Atr));
+
+ if ((cardIdentification.PcscDeviceClass == Pcsc.Common.DeviceClass.StorageClass) &&
+ (cardIdentification.PcscCardName == Pcsc.CardName.MifareUltralightC
+ || cardIdentification.PcscCardName == Pcsc.CardName.MifareUltralight
+ || cardIdentification.PcscCardName == Pcsc.CardName.MifareUltralightEV1))
{
- byte[] response = await mifareULAccess.ReadAsync((byte)(4 * i));
- LogMessage("Block " + (4 * i).ToString() + " to Block " + (4 * i + 3).ToString() + " " + BitConverter.ToString(response));
+ // Handle MIFARE Ultralight
+ MifareUltralight.AccessHandler mifareULAccess = new MifareUltralight.AccessHandler(connection);
+
+ // Each read should get us 16 bytes/4 blocks, so doing
+ // 4 reads will get us all 64 bytes/16 blocks on the card
+ for (byte i = 0; i < 4; i++)
+ {
+ byte[] response = await mifareULAccess.ReadAsync((byte)(4 * i));
+ LogMessage("Block " + (4 * i).ToString() + " to Block " + (4 * i + 3).ToString() + " " + BitConverter.ToString(response));
+ }
+
+ byte[] responseUid = await mifareULAccess.GetUidAsync();
+ LogMessage("UID: " + BitConverter.ToString(responseUid));
}
+ else if (cardIdentification.PcscDeviceClass == Pcsc.Common.DeviceClass.MifareDesfire)
+ {
+ // Handle MIFARE DESfire
+ Desfire.AccessHandler desfireAccess = new Desfire.AccessHandler(connection);
+ Desfire.CardDetails desfire = await desfireAccess.ReadCardDetailsAsync();
- byte[] responseUid = await mifareULAccess.GetUidAsync();
- LogMessage("UID: " + BitConverter.ToString(responseUid));
- }
- else if (cardIdentification.PcscDeviceClass == Pcsc.Common.DeviceClass.MifareDesfire)
- {
- // Handle MIFARE DESfire
- Desfire.AccessHandler desfireAccess = new Desfire.AccessHandler(connection);
- Desfire.CardDetails desfire = await desfireAccess.ReadCardDetailsAsync();
-
- LogMessage("DesFire Card Details: " + Environment.NewLine + desfire.ToString());
- }
- else if (cardIdentification.PcscDeviceClass == Pcsc.Common.DeviceClass.StorageClass
- && cardIdentification.PcscCardName == Pcsc.CardName.FeliCa)
- {
- // Handle Felica
- LogMessage("Felica card detected");
- var felicaAccess = new Felica.AccessHandler(connection);
- var uid = await felicaAccess.GetUidAsync();
- LogMessage("UID: " + BitConverter.ToString(uid));
- }
- else if (cardIdentification.PcscDeviceClass == Pcsc.Common.DeviceClass.StorageClass
- && (cardIdentification.PcscCardName == Pcsc.CardName.MifareStandard1K || cardIdentification.PcscCardName == Pcsc.CardName.MifareStandard4K))
- {
- // Handle MIFARE Standard/Classic
- LogMessage("MIFARE Standard/Classic card detected");
- var mfStdAccess = new MifareStandard.AccessHandler(connection);
- var uid = await mfStdAccess.GetUidAsync();
- LogMessage("UID: " + BitConverter.ToString(uid));
-
- ushort maxAddress = 0;
- switch (cardIdentification.PcscCardName)
+ LogMessage("DesFire Card Details: " + Environment.NewLine + desfire.ToString());
+ }
+ else if (cardIdentification.PcscDeviceClass == Pcsc.Common.DeviceClass.StorageClass
+ && cardIdentification.PcscCardName == Pcsc.CardName.FeliCa)
{
- case Pcsc.CardName.MifareStandard1K:
- maxAddress = 0x3f;
- break;
- case Pcsc.CardName.MifareStandard4K:
- maxAddress = 0xff;
- break;
+ // Handle Felica
+ LogMessage("Felica card detected");
+ var felicaAccess = new Felica.AccessHandler(connection);
+ var uid = await felicaAccess.GetUidAsync();
+ LogMessage("UID: " + BitConverter.ToString(uid));
}
- await mfStdAccess.LoadKeyAsync(MifareStandard.DefaultKeys.FactoryDefault);
-
- for (ushort address = 0; address <= maxAddress; address++)
+ else if (cardIdentification.PcscDeviceClass == Pcsc.Common.DeviceClass.StorageClass
+ && (cardIdentification.PcscCardName == Pcsc.CardName.MifareStandard1K || cardIdentification.PcscCardName == Pcsc.CardName.MifareStandard4K))
{
- var response = await mfStdAccess.ReadAsync(address, Pcsc.GeneralAuthenticate.GeneralAuthenticateKeyType.MifareKeyA);
- LogMessage("Block " + address.ToString() + " " + BitConverter.ToString(response));
+ // Handle MIFARE Standard/Classic
+ LogMessage("MIFARE Standard/Classic card detected");
+ var mfStdAccess = new MifareStandard.AccessHandler(connection);
+ var uid = await mfStdAccess.GetUidAsync();
+ LogMessage("UID: " + BitConverter.ToString(uid));
+
+ ushort maxAddress = 0;
+ switch (cardIdentification.PcscCardName)
+ {
+ case Pcsc.CardName.MifareStandard1K:
+ maxAddress = 0x3f;
+ break;
+ case Pcsc.CardName.MifareStandard4K:
+ maxAddress = 0xff;
+ break;
+ }
+ await mfStdAccess.LoadKeyAsync(MifareStandard.DefaultKeys.FactoryDefault);
+
+ for (ushort address = 0; address <= maxAddress; address++)
+ {
+ var response = await mfStdAccess.ReadAsync(address, Pcsc.GeneralAuthenticate.GeneralAuthenticateKeyType.MifareKeyA);
+ LogMessage("Block " + address.ToString() + " " + BitConverter.ToString(response));
+ }
}
- }
- else if (cardIdentification.PcscDeviceClass == Pcsc.Common.DeviceClass.StorageClass
- && (cardIdentification.PcscCardName == Pcsc.CardName.ICODE1 ||
- cardIdentification.PcscCardName == Pcsc.CardName.ICODESLI ||
- cardIdentification.PcscCardName == Pcsc.CardName.iCodeSL2))
- {
- // Handle ISO15693
- LogMessage("ISO15693 card detected");
- var iso15693Access = new Iso15693.AccessHandler(connection);
- var uid = await iso15693Access.GetUidAsync();
- LogMessage("UID: " + BitConverter.ToString(uid));
- }
- else
- {
- // Unknown card type
- // Note that when using the XDE emulator the card's ATR and type is not passed through, so we'll
- // end up here even for known card types if using the XDE emulator
-
- // Some cards might still let us query their UID with the PC/SC command, so let's try:
- var apduRes = await connection.TransceiveAsync(new Pcsc.GetUid());
- if (!apduRes.Succeeded)
+ else if (cardIdentification.PcscDeviceClass == Pcsc.Common.DeviceClass.StorageClass
+ && (cardIdentification.PcscCardName == Pcsc.CardName.ICODE1 ||
+ cardIdentification.PcscCardName == Pcsc.CardName.ICODESLI ||
+ cardIdentification.PcscCardName == Pcsc.CardName.iCodeSL2))
{
- LogMessage("Failure getting UID of card, " + apduRes.ToString());
+ // Handle ISO15693
+ LogMessage("ISO15693 card detected");
+ var iso15693Access = new Iso15693.AccessHandler(connection);
+ var uid = await iso15693Access.GetUidAsync();
+ LogMessage("UID: " + BitConverter.ToString(uid));
}
else
{
- LogMessage("UID: " + BitConverter.ToString(apduRes.ResponseData));
+ // Unknown card type
+ // Note that when using the XDE emulator the card's ATR and type is not passed through, so we'll
+ // end up here even for known card types if using the XDE emulator
+
+ // Some cards might still let us query their UID with the PC/SC command, so let's try:
+ var apduRes = await connection.TransceiveAsync(new Pcsc.GetUid());
+ if (!apduRes.Succeeded)
+ {
+ LogMessage("Failure getting UID of card, " + apduRes.ToString());
+ }
+ else
+ {
+ LogMessage("UID: " + BitConverter.ToString(apduRes.ResponseData));
+ }
}
}
-
- connection.Dispose();
}
catch(Exception ex)
{
diff --git a/Samples/Store/README.md b/Samples/Store/README.md
index 7d506862d2..b8abed5fdf 100644
--- a/Samples/Store/README.md
+++ b/Samples/Store/README.md
@@ -40,6 +40,10 @@ To obtain information about Microsoft Visual Studio 2015 and the tools for devel
## Related topics
+### Samples
+
+[Advertising](/Samples/Advertising)
+
### Reference
[**Windows.ApplicationModel.Store**](http://msdn.microsoft.com/library/windows/apps/br225197)
diff --git a/Samples/WRLOutOfProcessWinRTComponent/cpp/Server/WRLOutOfProcessWinRTComponent_server.vcxproj b/Samples/WRLOutOfProcessWinRTComponent/cpp/Server/WRLOutOfProcessWinRTComponent_server.vcxproj
index d4b8951bde..36e4ffbcee 100644
--- a/Samples/WRLOutOfProcessWinRTComponent/cpp/Server/WRLOutOfProcessWinRTComponent_server.vcxproj
+++ b/Samples/WRLOutOfProcessWinRTComponent/cpp/Server/WRLOutOfProcessWinRTComponent_server.vcxproj
@@ -114,7 +114,7 @@
false
- kernel32.lib;runtimeobject.lib;mincore.lib
+ runtimeobject.lib;mincore.lib
false
diff --git a/Samples/WRLOutOfProcessWinRTComponent/cpp/cpp/Package.appxmanifest b/Samples/WRLOutOfProcessWinRTComponent/cpp/cpp/Package.appxmanifest
index 468ddb3295..fa10b62b44 100644
--- a/Samples/WRLOutOfProcessWinRTComponent/cpp/cpp/Package.appxmanifest
+++ b/Samples/WRLOutOfProcessWinRTComponent/cpp/cpp/Package.appxmanifest
@@ -61,11 +61,12 @@
Microsoft.SDKSamples.Kitchen.Proxies.dll
+
+
+
-
-
-
+
diff --git a/Samples/WRLOutOfProcessWinRTComponent/cpp/cpp/Scenario4_CustomExceptionWRL.xaml.cpp b/Samples/WRLOutOfProcessWinRTComponent/cpp/cpp/Scenario4_CustomExceptionWRL.xaml.cpp
index 50604c86d4..f1274654f5 100644
--- a/Samples/WRLOutOfProcessWinRTComponent/cpp/cpp/Scenario4_CustomExceptionWRL.xaml.cpp
+++ b/Samples/WRLOutOfProcessWinRTComponent/cpp/cpp/Scenario4_CustomExceptionWRL.xaml.cpp
@@ -15,7 +15,7 @@ using namespace Microsoft::SDKSamples::Kitchen;
using namespace Windows::Foundation;
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Controls;
-using namespace SDKTemplate::WRLInProcessWinRTComponent;
+using namespace SDKTemplate::WRLOutOfProcessWinRTComponent;
CustomExceptionWRL::CustomExceptionWRL()
{
diff --git a/Samples/WRLOutOfProcessWinRTComponent/cpp/cs/Package.appxmanifest b/Samples/WRLOutOfProcessWinRTComponent/cpp/cs/Package.appxmanifest
index 93d641437c..df35fd42db 100644
--- a/Samples/WRLOutOfProcessWinRTComponent/cpp/cs/Package.appxmanifest
+++ b/Samples/WRLOutOfProcessWinRTComponent/cpp/cs/Package.appxmanifest
@@ -59,11 +59,12 @@
Microsoft.SDKSamples.Kitchen.Proxies.dll
+
+
+
-
-
-
+
diff --git a/Samples/WRLOutOfProcessWinRTComponent/cpp/cs/WRLOutOfProcessWinRTComponent_client_cs.csproj b/Samples/WRLOutOfProcessWinRTComponent/cpp/cs/WRLOutOfProcessWinRTComponent_client_cs.csproj
index 6562c413ac..f29b4cf1df 100644
--- a/Samples/WRLOutOfProcessWinRTComponent/cpp/cs/WRLOutOfProcessWinRTComponent_client_cs.csproj
+++ b/Samples/WRLOutOfProcessWinRTComponent/cpp/cs/WRLOutOfProcessWinRTComponent_client_cs.csproj
@@ -168,12 +168,8 @@
-
- {563e5bc0-fdff-413d-bd24-820119686520}
-
-
- {62635C39-BF9D-4AF6-A83E-5D6C20A105E5}
-
+
+
14.0
diff --git a/Samples/XamlListView/README.md b/Samples/XamlListView/README.md
index 99ae24f0f2..3b92d2891a 100644
--- a/Samples/XamlListView/README.md
+++ b/Samples/XamlListView/README.md
@@ -14,6 +14,7 @@ Specifically, this sample shows how to:
- **Master/Details plus Selection Sample:** How to implement a responsive master/details experience with a successful multiple selection experience.
- **Tap on the left edge of ListView:** Implement the behavior Tap on the left edge of ListView to going into multiple selection mode.
- **Restore Scroll Position Sample:** Demonstrates how to restore a list's scrollviewer position when a user navigates away and back from a page. Implements the ListViewPersistenceHelper API
+- **Scroll into View Sample:** Demonstrates how to scroll a specific item into view.
**Note** The Windows universal samples require Visual Studio 2015 to build and Windows 10 to execute.
diff --git a/Samples/XamlListView/cs/ListView.csproj b/Samples/XamlListView/cs/ListView.csproj
index 9540217266..29a3803466 100644
--- a/Samples/XamlListView/cs/ListView.csproj
+++ b/Samples/XamlListView/cs/ListView.csproj
@@ -115,6 +115,9 @@
RestoreScrollPositionSample.xaml
+
+ ScrollIntoViewSample.xaml
+
SimpleGridViewSample.xaml
@@ -221,6 +224,10 @@
Designer
MSBuild:Compile
+
+ Designer
+ MSBuild:Compile
+
MSBuild:Compile
Designer
diff --git a/Samples/XamlListView/cs/Samples/ScrollIntoViewSample/ScrollIntoViewSample.xaml b/Samples/XamlListView/cs/Samples/ScrollIntoViewSample/ScrollIntoViewSample.xaml
new file mode 100644
index 0000000000..89402453e9
--- /dev/null
+++ b/Samples/XamlListView/cs/Samples/ScrollIntoViewSample/ScrollIntoViewSample.xaml
@@ -0,0 +1,85 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Default
+
+
+
+
+ Leading
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Samples/XamlListView/cs/Samples/ScrollIntoViewSample/ScrollIntoViewSample.xaml.cs b/Samples/XamlListView/cs/Samples/ScrollIntoViewSample/ScrollIntoViewSample.xaml.cs
new file mode 100644
index 0000000000..d8daaf8fed
--- /dev/null
+++ b/Samples/XamlListView/cs/Samples/ScrollIntoViewSample/ScrollIntoViewSample.xaml.cs
@@ -0,0 +1,43 @@
+using ListViewSample.Model;
+using System;
+using System.Collections.ObjectModel;
+using Windows.UI;
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Controls;
+using Windows.UI.Xaml.Media;
+
+namespace ListViewSample
+{
+ public sealed partial class ScrollIntoViewSample : Page
+ {
+ private ObservableCollection- _items;
+ private SolidColorBrush InvalidFormat = new SolidColorBrush(Colors.Red);
+ private SolidColorBrush ValidFormat = new SolidColorBrush(Colors.Green);
+ public ScrollIntoViewSample()
+ {
+ this.InitializeComponent();
+ _items = Item.GetItems(1000);
+ }
+
+ private void ShowSplitView(object sender, RoutedEventArgs e)
+ {
+ MySamplesPane.SamplesSplitView.IsPaneOpen = !MySamplesPane.SamplesSplitView.IsPaneOpen;
+ }
+
+ private void Scroll_Click(object sender, RoutedEventArgs e)
+ {
+ int numVal;
+ if (Int32.TryParse(scrollId.Text, out numVal) && numVal >= 0 && numVal < ItemsListView.Items.Count)
+ {
+ var item = (ComboBoxItem)ScrollAlignment.SelectedItem;
+ var Alignment = (ScrollIntoViewAlignment)item.Tag;
+ ItemsListView.ScrollIntoView(ItemsListView.Items[numVal], Alignment);
+ scrollId.BorderBrush = ValidFormat;
+ }
+ else
+ {
+ scrollId.BorderBrush = InvalidFormat;
+ }
+ }
+ }
+}
diff --git a/Samples/XamlListView/cs/SamplesPane.xaml b/Samples/XamlListView/cs/SamplesPane.xaml
index 9eafc6ff64..305f6070f8 100644
--- a/Samples/XamlListView/cs/SamplesPane.xaml
+++ b/Samples/XamlListView/cs/SamplesPane.xaml
@@ -39,6 +39,11 @@
Style="{StaticResource HomeButtonStyle}"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Left" />
+
diff --git a/Samples/XamlListView/cs/SamplesPane.xaml.cs b/Samples/XamlListView/cs/SamplesPane.xaml.cs
index e0a06c5626..a9df4951e1 100644
--- a/Samples/XamlListView/cs/SamplesPane.xaml.cs
+++ b/Samples/XamlListView/cs/SamplesPane.xaml.cs
@@ -33,5 +33,10 @@ private void NavigateToHome(object sender, RoutedEventArgs e)
{
((Frame)Window.Current.Content).Navigate(typeof(MainPage));
}
+
+ private void NavigateToSpecificPosition(object sender, RoutedEventArgs e)
+ {
+ ((Frame)Window.Current.Content).Navigate(typeof(ScrollIntoViewSample));
+ }
}
}
diff --git a/Samples/XamlWebView/README.md b/Samples/XamlWebView/README.md
new file mode 100644
index 0000000000..c694b2609c
--- /dev/null
+++ b/Samples/XamlWebView/README.md
@@ -0,0 +1,96 @@
+
+
+# WebView control (XAML) sample
+
+This sample demonstrates how to use the
+XAML [**WebView**](https://msdn.microsoft.com/library/windows/apps/windows.ui.xaml.controls.webview.aspx)
+control.
+
+Specifically, this sample shows how to
+
+* Load different types of content into the WebView
+ * Navigate the Webview to a URI with the
+ [**Navigate**](https://msdn.microsoft.com/library/windows/apps/windows.ui.xaml.controls.webview.navigate.aspx)
+ method.
+ * Load string content into the WebView with the
+ [**NavigateToString**](https://msdn.microsoft.com/library/windows/apps/windows.ui.xaml.controls.webview.navigatetostring.aspx)
+ method.
+ * Load a file from the app package into the WebView using the
+ [**ms-appx-web**](https://technet.microsoft.com/scriptcenter/jj655406#ms_appx_web) protocol.
+ * Load a file from the app's file system storage into the WebView using the
+ [**ms-appdata**](https://technet.microsoft.com/scriptcenter/jj655406#ms_appdata) protocol.
+ * Custom loading of HTML and support files (such as CSS, script, and images) with the
+ [**NavigateToLocalStreamUri**](https://msdn.microsoft.com/library/windows/apps/windows.ui.xaml.controls.webview.navigatetolocalstreamuri.aspx)
+ method
+ and an implementation of the
+ [**IUriToStreamResolver**](https://msdn.microsoft.com/library/windows/apps/windows.web.iuritostreamresolver.aspx)
+ interface.
+
+* Obtain information about the WebView
+ * Show a progress ring and Stop button during loading.
+ * Update the Backward and Forward buttons based on the WebView navigation history.
+ * Obtain a screenshot of the current WebView content with the
+ [**CapturePreviewToStreamAsync**](https://msdn.microsoft.com/library/windows/apps/windows.ui.xaml.controls.webview.capturepreviewtostreamasync.aspx)
+ method.
+
+* Interact with the WebView
+ * Call a JavaScript function in the WebView and obtain the result
+ with the
+ [**InvokeScriptAsync**](https://msdn.microsoft.com/library/windows/apps/windows.ui.xaml.controls.webview.invokescriptasync.aspx)
+ method.
+ * Receive information from WebView-hosted script by handling the
+ [**ScriptNotify**](https://msdn.microsoft.com/library/windows/apps/windows.ui.xaml.controls.webview.scriptnotify.aspx)
+ event.
+ * Respond to requests from the WebView to enter full screen.
+
+* Support the Share contract by using the
+ [**CaptureSelectedContentToDataPackageAsync**](https://msdn.microsoft.com/library/windows/apps/windows.ui.xaml.controls.webview.captureselectedcontenttodatapackageasync.aspx)
+ method to obtain the current selection of the WebView.
+
+**Note** The Windows universal samples require Visual Studio 2015 to build and Windows 10 to execute.
+
+To obtain information about Windows 10 development, go to the [Windows Dev Center](https://dev.windows.com)
+
+To obtain information about Microsoft Visual Studio 2015 and the tools for developing Windows apps, go to [Visual Studio 2015](http://go.microsoft.com/fwlink/?LinkID=532422)
+
+## Related topics
+
+### Samples
+
+* [FullScreenMode](../FullScreenMode)
+* [ShareSource](../ShareSource)
+
+### Reference
+
+* [**WebView** control](https://msdn.microsoft.com/library/windows/apps/windows.ui.xaml.controls.webview.aspx)
+* [**IUriToStreamResolver** interface](https://msdn.microsoft.com/library/windows/apps/windows.web.iuritostreamresolver.aspx)
+
+## System requirements
+
+**Client:** Windows 10
+
+**Server:** Windows Server 2016 Technical Preview
+
+**Phone:** Windows 10
+
+## Build the sample
+
+1. If you download the samples ZIP, be sure to unzip the entire archive, not just the folder with the sample you want to build.
+2. Start Microsoft Visual Studio 2015 and select **File** \> **Open** \> **Project/Solution**.
+3. Starting in the folder where you unzipped the samples, go to the Samples subfolder, then the subfolder for this specific sample, then the subfolder for your preferred language (C++, C#, or JavaScript). Double-click the Visual Studio 2015 Solution (.sln) file.
+4. Press Ctrl+Shift+B, or select **Build** \> **Build Solution**.
+
+## Run the sample
+
+The next steps depend on whether you just want to deploy the sample or you want to both deploy and run it.
+
+### Deploying the sample
+
+- Select Build > Deploy Solution.
+
+### Deploying and running the sample
+
+- To debug the sample and then run it, press F5 or select Debug > Start Debugging. To run the sample without debugging, press Ctrl+F5 or selectDebug > Start Without Debugging.
diff --git a/Samples/XamlWebView/cs/Package.appxmanifest b/Samples/XamlWebView/cs/Package.appxmanifest
new file mode 100644
index 0000000000..46af4c5ac1
--- /dev/null
+++ b/Samples/XamlWebView/cs/Package.appxmanifest
@@ -0,0 +1,42 @@
+
+
+
+
+
+ XamlWebView C# Sample
+ Microsoft Corporation
+ Assets\StoreLogo-sdk.png
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Samples/XamlWebView/cs/SampleConfiguration.cs b/Samples/XamlWebView/cs/SampleConfiguration.cs
new file mode 100644
index 0000000000..ef84f8fab9
--- /dev/null
+++ b/Samples/XamlWebView/cs/SampleConfiguration.cs
@@ -0,0 +1,51 @@
+//*********************************************************
+//
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the MIT License (MIT).
+// 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 System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using Windows.Storage;
+using Windows.UI.Xaml.Controls;
+
+namespace SDKTemplate
+{
+ public partial class MainPage : Page
+ {
+ public const string FEATURE_NAME = "XAML WebView Control";
+
+ List scenarios = new List
+ {
+ new Scenario() { Title="Navigate to URL", ClassType=typeof(Scenario1_NavToUrl)},
+ new Scenario() { Title="Navigate to string", ClassType=typeof(Scenario2_NavToString)},
+ new Scenario() { Title="Invoke script", ClassType=typeof(Scenario3_InvokeScript)},
+ new Scenario() { Title="Script notify", ClassType=typeof(Scenario4_ScriptNotify)},
+ new Scenario() { Title="Navigate to package and local state", ClassType=typeof(Scenario5_NavToFiles)},
+ new Scenario() { Title="Navigate with custom resolver", ClassType=typeof(Scenario6_NavToStream)},
+ new Scenario() { Title="Share content", ClassType=typeof(Scenario7_Share)},
+ new Scenario() { Title="Capture bitmap", ClassType=typeof(Scenario8_CaptureBitmap)},
+ new Scenario() { Title="Full-screen mode", ClassType=typeof(Scenario9_ContainsFullScreenElement)},
+ new Scenario() { Title="Unviewable content", ClassType=typeof(Scenario10_UnviewableContent) },
+ };
+
+ public static async Task LoadStringFromPackageFileAsync(string name)
+ {
+ // Using the storage classes to read the content from a file as a string.
+ StorageFile f = await StorageFile.GetFileFromApplicationUriAsync(new Uri($"ms-appx:///html/{name}"));
+ return await FileIO.ReadTextAsync(f);
+ }
+}
+
+ public class Scenario
+ {
+ public string Title { get; set; }
+ public Type ClassType { get; set; }
+ }
+}
diff --git a/Samples/XamlWebView/cs/Scenario10_UnviewableContent.xaml b/Samples/XamlWebView/cs/Scenario10_UnviewableContent.xaml
new file mode 100644
index 0000000000..d01036f232
--- /dev/null
+++ b/Samples/XamlWebView/cs/Scenario10_UnviewableContent.xaml
@@ -0,0 +1,42 @@
+
+
+
+
+
+
+
+
+
+
+
+ Unviewable content
+
+
+ When an attempt is made to load content that the WebView can't show,
+ the app can show the content in some other way.
+ This scenario opens PDF files with the system launcher.
+
+
+
+
+
+
+
+
diff --git a/Samples/XamlWebView/cs/Scenario10_UnviewableContent.xaml.cs b/Samples/XamlWebView/cs/Scenario10_UnviewableContent.xaml.cs
new file mode 100644
index 0000000000..35d43811d0
--- /dev/null
+++ b/Samples/XamlWebView/cs/Scenario10_UnviewableContent.xaml.cs
@@ -0,0 +1,56 @@
+//*********************************************************
+//
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the MIT License (MIT).
+// 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.UI.ViewManagement;
+
+namespace SDKTemplate
+{
+ ///
+ /// An empty page that can be used on its own or navigated to within a Frame.
+ ///
+ public sealed partial class Scenario10_UnviewableContent : Page
+ {
+ private MainPage rootPage = MainPage.Current;
+
+ public Scenario10_UnviewableContent()
+ {
+ this.InitializeComponent();
+ }
+
+ protected override void OnNavigatedTo(NavigationEventArgs e)
+ {
+ WebViewControl.Navigate(new Uri("https://www.bing.com/search?q=site%3Amicrosoft.com+filetype%3Apdf"));
+ }
+
+ private async void WebViewControl_UnviewableContentIdentified(WebView sender, WebViewUnviewableContentIdentifiedEventArgs args)
+ {
+ if (args.Uri.AbsolutePath.EndsWith(".pdf"))
+ {
+ if (await Windows.System.Launcher.LaunchUriAsync(args.Uri))
+ {
+ rootPage.NotifyUser($"Launched {args.Uri} with system launcher", NotifyType.StatusMessage);
+ }
+ else
+ {
+ rootPage.NotifyUser($"Failed to launch {args.Uri}", NotifyType.ErrorMessage);
+ }
+ } else
+ {
+ rootPage.NotifyUser($"Blocked unknown file type of {args.Uri}", NotifyType.ErrorMessage);
+ }
+ }
+ }
+}
diff --git a/Samples/XamlWebView/cs/Scenario1_NavToUrl.xaml b/Samples/XamlWebView/cs/Scenario1_NavToUrl.xaml
new file mode 100644
index 0000000000..78ec57552a
--- /dev/null
+++ b/Samples/XamlWebView/cs/Scenario1_NavToUrl.xaml
@@ -0,0 +1,61 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ Navigate to URL
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Samples/XamlWebView/cs/Scenario1_NavToUrl.xaml.cs b/Samples/XamlWebView/cs/Scenario1_NavToUrl.xaml.cs
new file mode 100644
index 0000000000..fc6d30e6c7
--- /dev/null
+++ b/Samples/XamlWebView/cs/Scenario1_NavToUrl.xaml.cs
@@ -0,0 +1,199 @@
+//*********************************************************
+//
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the MIT License (MIT).
+// 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 System;
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Controls;
+using Windows.UI.Xaml.Documents;
+using Windows.UI.Xaml.Input;
+
+namespace SDKTemplate
+{
+ public sealed partial class Scenario1_NavToUrl : Page
+ {
+ public Scenario1_NavToUrl()
+ {
+ this.InitializeComponent();
+ }
+
+ static string UriToString(Uri uri)
+ {
+ return (uri != null) ? uri.ToString() : "";
+ }
+
+ ///
+ /// This is the click handler for the "Go" button.
+ ///
+ ///
+ ///
+ private void GoButton_Click()
+ {
+ if (!pageIsLoading)
+ {
+ NavigateWebview(AddressBox.Text);
+ }
+ else
+ {
+ WebViewControl.Stop();
+ pageIsLoading = false;
+ }
+ }
+
+ ///
+ /// Property to control the "Go" button text, forward/backward buttons and progress ring.
+ ///
+ private bool _pageIsLoading;
+ bool pageIsLoading
+ {
+ get { return _pageIsLoading; }
+ set
+ {
+ _pageIsLoading = value;
+ GoButton.Content = (value ? "Stop" : "Go");
+ ProgressControl.IsActive = value;
+
+ if (!value)
+ {
+ NavigateBackButton.IsEnabled = WebViewControl.CanGoBack;
+ NavigateForwardButton.IsEnabled = WebViewControl.CanGoForward;
+ }
+ }
+ }
+
+ ///
+ /// Handler for the NavigateBackward button
+ ///
+ ///
+ ///
+ private void NavigateBackward_Click()
+ {
+ if (WebViewControl.CanGoBack) WebViewControl.GoBack();
+ }
+
+ ///
+ /// Handler for the GoForward button
+ ///
+ ///
+ ///
+ private void NavigateForward_Click()
+ {
+ if (WebViewControl.CanGoForward) WebViewControl.GoForward();
+ }
+
+ ///
+ /// This handles the enter key in the url address box
+ ///
+ ///
+ ///
+ void Address_KeyUp(object sender, KeyRoutedEventArgs e)
+ {
+ if (e.Key == Windows.System.VirtualKey.Enter)
+ {
+ NavigateWebview(AddressBox.Text);
+ }
+ }
+
+ ///
+ /// Helper to perform the navigation in webview
+ ///
+ ///
+ private void NavigateWebview(string url)
+ {
+ try
+ {
+ Uri targetUri = new Uri(url);
+ WebViewControl.Navigate(targetUri);
+ }
+ catch (UriFormatException ex)
+ {
+ // Bad address
+ AppendLog($"Address is invalid, try again. Error: {ex.Message}.");
+ }
+ }
+
+ ///
+ /// Handle the event that indicates that WebView is starting a navigation.
+ ///
+ ///
+ ///
+ void WebViewControl_NavigationStarting(WebView sender, WebViewNavigationStartingEventArgs args)
+ {
+ string url = UriToString(args.Uri);
+ AddressBox.Text = url;
+ AppendLog($"Starting navigation to: \"{url}\".");
+ pageIsLoading = true;
+ }
+
+ ///
+ /// Handle the event that indicates that the WebView content is not a web page.
+ /// For example, it may be a file download.
+ ///
+ ///
+ ///
+ void WebViewControl_UnviewableContentIdentified(WebView sender, WebViewUnviewableContentIdentifiedEventArgs args)
+ {
+ AppendLog($"Content for \"{UriToString(args.Uri)}\" cannot be loaded into webview.");
+ // We throw away the request. See the "Unviewable content" scenario for other
+ // ways of handling the event.
+ pageIsLoading = false;
+ }
+
+ ///
+ /// Handle the event that indicates that WebView has resolved the URI, and that it is loading HTML content.
+ ///
+ ///
+ ///
+ void WebViewControl_ContentLoading(WebView sender, WebViewContentLoadingEventArgs args)
+ {
+ AppendLog($"Loading content for \"{UriToString(args.Uri)}\".");
+ }
+
+
+ ///
+ /// Handle the event that indicates that the WebView content is fully loaded.
+ /// If you need to invoke script, it is best to wait for this event.
+ ///
+ ///
+ ///
+ void WebViewControl_DOMContentLoaded(WebView sender, WebViewDOMContentLoadedEventArgs args)
+ {
+ AppendLog($"Content for \"{UriToString(args.Uri)}\" has finished loading.");
+ }
+
+ ///
+ /// Event to indicate webview has completed the navigation, either with success or failure.
+ ///
+ ///
+ ///
+ void WebViewControl_NavigationCompleted(WebView sender, WebViewNavigationCompletedEventArgs args)
+ {
+ pageIsLoading = false;
+ if (args.IsSuccess)
+ {
+ AppendLog($"Navigation to \"{UriToString(args.Uri)}\" completed successfully.");
+ }
+ else
+ {
+ AppendLog($"Navigation to: \"{UriToString(args.Uri)}\" failed with error {args.WebErrorStatus}.");
+ }
+ }
+
+ ///
+ /// Helper for logging
+ ///
+ ///
+ void AppendLog(string logEntry)
+ {
+ logResults.Inlines.Add(new Run { Text = logEntry + "\n" });
+ logScroller.ChangeView(0, logScroller.ScrollableHeight, null);
+ }
+ }
+}
diff --git a/Samples/XamlWebView/cs/Scenario2_NavToString.xaml b/Samples/XamlWebView/cs/Scenario2_NavToString.xaml
new file mode 100644
index 0000000000..3d96f34c8c
--- /dev/null
+++ b/Samples/XamlWebView/cs/Scenario2_NavToString.xaml
@@ -0,0 +1,53 @@
+
+
+
+
+
+
+
+
+
+
+
+ Navigate to string
+
+
+ Loads string content into the WebView control.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Samples/XamlWebView/cs/Scenario2_NavToString.xaml.cs b/Samples/XamlWebView/cs/Scenario2_NavToString.xaml.cs
new file mode 100644
index 0000000000..a947657c7b
--- /dev/null
+++ b/Samples/XamlWebView/cs/Scenario2_NavToString.xaml.cs
@@ -0,0 +1,41 @@
+//*********************************************************
+//
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the MIT License (MIT).
+// 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.Storage;
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Controls;
+using Windows.UI.Xaml.Navigation;
+using System;
+
+namespace SDKTemplate
+{
+ ///
+ /// An empty page that can be used on its own or navigated to within a Frame.
+ ///
+ public sealed partial class Scenario2_NavToString : Page
+ {
+ public Scenario2_NavToString()
+ {
+ this.InitializeComponent();
+ }
+
+ protected override async void OnNavigatedTo(NavigationEventArgs e)
+ {
+ HtmlBox.Text = await MainPage.LoadStringFromPackageFileAsync("html_example.html");
+ }
+
+ private void LoadAsHtml()
+ {
+ // Grab the HTML from the text box and load it into the WebView
+ WebViewControl.NavigateToString(HtmlBox.Text);
+ }
+ }
+}
diff --git a/Samples/XamlWebView/cs/Scenario3_InvokeScript.xaml b/Samples/XamlWebView/cs/Scenario3_InvokeScript.xaml
new file mode 100644
index 0000000000..11e522108c
--- /dev/null
+++ b/Samples/XamlWebView/cs/Scenario3_InvokeScript.xaml
@@ -0,0 +1,58 @@
+
+
+
+
+
+
+
+
+
+
+
+ Invoke script
+
+
+ Click "Load HTML" to load the HTML into the WebView control, then
+ click "Invoke script" to call the JavaScript function "doSomething"
+ and display the string result.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Samples/XamlWebView/cs/Scenario3_InvokeScript.xaml.cs b/Samples/XamlWebView/cs/Scenario3_InvokeScript.xaml.cs
new file mode 100644
index 0000000000..601bc0e24a
--- /dev/null
+++ b/Samples/XamlWebView/cs/Scenario3_InvokeScript.xaml.cs
@@ -0,0 +1,70 @@
+//*********************************************************
+//
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the MIT License (MIT).
+// 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.Controls;
+using Windows.UI.Xaml.Navigation;
+using System;
+
+namespace SDKTemplate
+{
+ public sealed partial class Scenario3_InvokeScript : Page
+ {
+ private MainPage rootPage = MainPage.Current;
+
+ public Scenario3_InvokeScript()
+ {
+ this.InitializeComponent();
+ }
+
+ protected override async void OnNavigatedTo(NavigationEventArgs e)
+ {
+ HtmlBox.Text = await MainPage.LoadStringFromPackageFileAsync("script_example.html");
+ }
+
+ private void LoadHtml()
+ {
+ // Grab the HTML from the text box and load it into the WebView.
+ WebViewControl.NavigateToString(HtmlBox.Text);
+ }
+
+ private async void InvokeScript()
+ {
+ // Invoke the javascript function called 'doSomething' that is loaded into the WebView.
+ try
+ {
+ string result = await WebViewControl.InvokeScriptAsync("doSomething", null);
+ rootPage.NotifyUser($"Script returned \"{result}\"", NotifyType.StatusMessage);
+ }
+ catch (Exception ex)
+ {
+ string errorText = null;
+ switch (ex.HResult)
+ {
+ case unchecked((int)0x80020006):
+ errorText = "There is no function called doSomething";
+ break;
+ case unchecked((int)0x80020101):
+ errorText = "A JavaScript error or exception occured while executing the function doSomething";
+ break;
+
+ case unchecked((int)0x800a138a):
+ errorText = "doSomething is not a function";
+ break;
+ default:
+ // Some other error occurred.
+ errorText = ex.Message;
+ break;
+ }
+ rootPage.NotifyUser(errorText, NotifyType.ErrorMessage);
+ }
+ }
+ }
+}
diff --git a/Samples/XamlWebView/cs/Scenario4_ScriptNotify.xaml b/Samples/XamlWebView/cs/Scenario4_ScriptNotify.xaml
new file mode 100644
index 0000000000..49a7d17c03
--- /dev/null
+++ b/Samples/XamlWebView/cs/Scenario4_ScriptNotify.xaml
@@ -0,0 +1,48 @@
+
+
+
+
+
+
+
+
+
+
+
+ Script notify
+
+
+ When a script calls window.external.notify(value),
+ the ScriptNotify event is raised with the specified value.
+ Show more information
+
+
+ The following pages can call window.external.notify:
+
+ ● Content loaded using the NavigateToString() method; or ms-appx-web, ms-appdata, ms-webview-stream:// URI
+ schemes.
+
+ ● Content loaded from the web, provided they use the https:// protocol, and the site is listed
+ in the app's manifest under the Content Uri's node.
+
+
+
+
+
diff --git a/Samples/XamlWebView/cs/Scenario4_ScriptNotify.xaml.cs b/Samples/XamlWebView/cs/Scenario4_ScriptNotify.xaml.cs
new file mode 100644
index 0000000000..4b8b3b08ed
--- /dev/null
+++ b/Samples/XamlWebView/cs/Scenario4_ScriptNotify.xaml.cs
@@ -0,0 +1,53 @@
+//*********************************************************
+//
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the MIT License (MIT).
+// 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 System;
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Controls;
+using Windows.UI.Xaml.Documents;
+
+namespace SDKTemplate
+{
+ public sealed partial class Scenario4_ScriptNotify : Page
+ {
+ MainPage rootPage = MainPage.Current;
+
+ public Scenario4_ScriptNotify()
+ {
+ this.InitializeComponent();
+ WebViewControl.Navigate(new Uri("ms-appx-web:///html/scriptNotify_example.html"));
+ }
+
+ void WebViewControl_ScriptNotify(object sender, NotifyEventArgs e)
+ {
+ // Be sure to verify the source of the message when performing actions with the data.
+ // As webview can be navigated, you need to check that the message is coming from a page/code
+ // that you trust.
+ rootPage.NotifyUser($"Event received from {e.CallingUri}: \"{e.Value}\"", NotifyType.StatusMessage);
+ }
+
+ private void MoreLess_Click(Hyperlink sender, HyperlinkClickEventArgs args)
+ {
+ var hyperlink = (Hyperlink)sender;
+ if (MoreInformationText.Visibility == Visibility.Visible)
+ {
+ MoreInformationText.Visibility = Visibility.Collapsed;
+ MoreLessText.Text = "Show more information";
+ }
+ else
+ {
+ MoreInformationText.Visibility = Visibility.Visible;
+ MoreLessText.Text = "Show less information";
+ }
+ rootPage.NotifyUser("", NotifyType.StatusMessage);
+ }
+ }
+}
diff --git a/Samples/XamlWebView/cs/Scenario5_NavToFiles.xaml b/Samples/XamlWebView/cs/Scenario5_NavToFiles.xaml
new file mode 100644
index 0000000000..03fc806bc7
--- /dev/null
+++ b/Samples/XamlWebView/cs/Scenario5_NavToFiles.xaml
@@ -0,0 +1,47 @@
+
+
+
+
+
+
+
+ Navigate to package and local state
+
+
+ The WebView control can navigate to files in the
+ package or app state directories using the ms-appx-web:
+ and ms-appdata: protocols.
+ These protocols use a built-in
+ stream resolver object.
+ See the "Navigate with custom resolver" scenario
+ for a demonstration of a custom stream resolver object.
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Samples/XamlWebView/cs/Scenario5_NavToFiles.xaml.cs b/Samples/XamlWebView/cs/Scenario5_NavToFiles.xaml.cs
new file mode 100644
index 0000000000..ed085ec0a3
--- /dev/null
+++ b/Samples/XamlWebView/cs/Scenario5_NavToFiles.xaml.cs
@@ -0,0 +1,61 @@
+//*********************************************************
+//
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the MIT License (MIT).
+// 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.Storage;
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Controls;
+using Windows.UI.Xaml.Navigation;
+using System;
+
+namespace SDKTemplate
+{
+ public sealed partial class Scenario5_NavToFiles : Page
+ {
+ private MainPage rootPage = MainPage.Current;
+
+ public Scenario5_NavToFiles()
+ {
+ this.InitializeComponent();
+ }
+
+ ///
+ /// Navigates the webview to the application package
+ ///
+ ///
+ ///
+ private void LoadFromPackage_Click()
+ {
+ string url = "ms-appx-web:///html/html_example2.html";
+ WebViewControl.Navigate(new Uri(url));
+ rootPage.NotifyUser($"Navigated to {url}", NotifyType.StatusMessage);
+ }
+
+ ///
+ /// Navigates the webview to the local state directory
+ ///
+ ///
+ ///
+ private async void LoadFromLocalState_Click()
+ {
+ // Create a file in a subdirectory.
+ // The ms-appdata protocol isolates top-level subdirectories from each other.
+
+ StorageFolder stateFolder = await ApplicationData.Current.LocalFolder.CreateFolderAsync("NavigateToState", CreationCollisionOption.OpenIfExists);
+ StorageFile htmlFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri($"ms-appx:///html/html_example2.html"));
+
+ await htmlFile.CopyAsync(stateFolder, "test.html", NameCollisionOption.ReplaceExisting);
+
+ string url = "ms-appdata:///local/NavigateToState/test.html";
+ WebViewControl.Navigate(new Uri(url));
+ rootPage.NotifyUser($"Navigated to {url}", NotifyType.StatusMessage);
+ }
+ }
+}
diff --git a/Samples/XamlWebView/cs/Scenario6_NavToStream.xaml b/Samples/XamlWebView/cs/Scenario6_NavToStream.xaml
new file mode 100644
index 0000000000..a4b4c52b67
--- /dev/null
+++ b/Samples/XamlWebView/cs/Scenario6_NavToStream.xaml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+ Navigate with custom resolver
+
+
+ Web pages commonly reference other files, such
+ as css, script or images. Sometimes those resources are not directly
+ accessible using existing URI schemes.
+ The ms-webview-stream:// URI scheme allows the app to perform custom URI handling.
+
+
+
+
+
+
+
+
diff --git a/Samples/XamlWebView/cs/Scenario6_NavToStream.xaml.cs b/Samples/XamlWebView/cs/Scenario6_NavToStream.xaml.cs
new file mode 100644
index 0000000000..7d4f843507
--- /dev/null
+++ b/Samples/XamlWebView/cs/Scenario6_NavToStream.xaml.cs
@@ -0,0 +1,107 @@
+//*********************************************************
+//
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the MIT License (MIT).
+// 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 System;
+using System.IO;
+using System.Runtime.InteropServices.WindowsRuntime;
+using System.Threading.Tasks;
+using Windows.Foundation;
+using Windows.Security.Cryptography;
+using Windows.Storage.Streams;
+using Windows.UI.Xaml.Controls;
+using Windows.UI.Xaml.Navigation;
+
+namespace SDKTemplate
+{
+ ///
+ /// An empty page that can be used on its own or navigated to within a Frame.
+ ///
+ public sealed partial class Scenario6_NavToStream : Page
+ {
+ private StreamUriWinRTResolver myResolver;
+
+ public Scenario6_NavToStream()
+ {
+ myResolver = new StreamUriWinRTResolver();
+ this.InitializeComponent();
+ }
+
+ protected override void OnNavigatedTo(NavigationEventArgs e)
+ {
+ // The 'Host' part of the URI for the ms-local-stream protocol is a combination of the package name
+ // and an application-defined key, which identifies the specfic resolver.
+ // Here, we use 'MyTag'.
+
+ Uri url = WebViewControl.BuildLocalStreamUri("MyTag", "/default.html");
+
+ // The resolver object needs to be passed in to the navigate call.
+ WebViewControl.NavigateToLocalStreamUri(url, myResolver);
+ }
+
+ ///
+ /// Sample URI resolver object for use with NavigateToLocalStreamUri.
+ /// The object must implement the IUriToStreamResolver interface
+ ///
+ /// Note: If your content is stored in the package or local state,
+ /// then you can use the ms-appx-web: or ms-appdata: protocol demonstrated in the
+ /// "Navigate to package and local state" scenario. Those protocols will
+ /// will create a resolver for you.
+ ///
+ public sealed class StreamUriWinRTResolver : Windows.Web.IUriToStreamResolver
+ {
+ ///
+ /// The entry point for resolving a URI to a stream.
+ ///
+ ///
+ ///
+ public IAsyncOperation UriToStreamAsync(Uri uri)
+ {
+ // Because of the signature of the this method, it can't use await, so we
+ // call into a separate helper method that can use the C# await pattern.
+ return GetContentAsync(uri).AsAsyncOperation();
+ }
+
+
+ ///
+ /// Helper that produces the contents corresponding to a Uri.
+ /// Uses the C# await pattern to coordinate async operations.
+ ///
+ ///
+ ///
+ private async Task GetContentAsync(Uri uri)
+ {
+ string path = uri.AbsolutePath;
+ string contents;
+
+ switch (path)
+ {
+ case "/default.html":
+ contents = await MainPage.LoadStringFromPackageFileAsync("stream_example.html");
+ contents = contents.Replace("%", Windows.ApplicationModel.Package.Current.Id.Name);
+ break;
+
+ case "/stream.css":
+ contents = "p { color: blue; }";
+ break;
+
+ default:
+ throw new Exception($"Could not resolve URI \"{uri}\"");
+ }
+
+ // Convert the string to a stream.
+ IBuffer buffer = CryptographicBuffer.ConvertStringToBinary(contents, BinaryStringEncoding.Utf8);
+ var stream = new InMemoryRandomAccessStream();
+ await stream.WriteAsync(buffer);
+ return stream.GetInputStreamAt(0);
+ }
+ }
+ }
+}
diff --git a/Samples/XamlWebView/cs/Scenario7_Share.xaml b/Samples/XamlWebView/cs/Scenario7_Share.xaml
new file mode 100644
index 0000000000..045ecf5f1d
--- /dev/null
+++ b/Samples/XamlWebView/cs/Scenario7_Share.xaml
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
+
+
+
+ Share content
+
+
+ After the page loads,
+ select some part of the content and then hit the "Share Content" button.
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Samples/XamlWebView/cs/Scenario7_Share.xaml.cs b/Samples/XamlWebView/cs/Scenario7_Share.xaml.cs
new file mode 100644
index 0000000000..1384244b73
--- /dev/null
+++ b/Samples/XamlWebView/cs/Scenario7_Share.xaml.cs
@@ -0,0 +1,124 @@
+//*********************************************************
+//
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the MIT License (MIT).
+// 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 SDKTemplate
+{
+ ///
+ /// An empty page that can be used on its own or navigated to within a Frame.
+ ///
+ public sealed partial class Scenario7_Share : Page
+ {
+ private MainPage rootPage;
+
+ public Scenario7_Share()
+ {
+ this.InitializeComponent();
+ }
+
+ ///
+ /// Invoked when this page is about to be displayed in a Frame.
+ ///
+ /// Event data that describes how this page was reached. The Parameter
+ /// property is typically used to configure the page.
+ protected override void OnNavigatedTo(NavigationEventArgs e)
+ {
+ rootPage = MainPage.Current;
+
+ WebViewControl.Navigate(new Uri("http://www.microsoft.com"));
+
+ // Register for the share event
+ DataTransferManager.GetForCurrentView().DataRequested += DataTransferManager_DataRequested;
+ }
+
+ protected override void OnNavigatedFrom(NavigationEventArgs e)
+ {
+ // Unregister for the share event
+ DataTransferManager.GetForCurrentView().DataRequested -= DataTransferManager_DataRequested;
+ }
+
+ void WebViewControl_NavigationStarting(WebView sender, WebViewNavigationStartingEventArgs args)
+ {
+ ProgressControl.IsActive = true;
+ }
+
+ void WebViewControl_NavigationCompleted(WebView sender, WebViewNavigationCompletedEventArgs args)
+ {
+ ProgressControl.IsActive = false;
+ }
+
+ private void ShareContent_Click(object sender, RoutedEventArgs e)
+ {
+ // Show the share UI
+ DataTransferManager.ShowShareUI();
+ }
+
+ ///
+ /// Raised when the user initiates a Share operation.
+ ///
+ ///
+ ///
+ async void DataTransferManager_DataRequested(DataTransferManager sender, DataRequestedEventArgs args)
+ {
+ DataRequest request = args.Request;
+ // We are going to use an async API to talk to the webview, so get a deferral to give
+ // us time to generate the results.
+ DataRequestDeferral deferral = request.GetDeferral();
+ DataPackage dp = await WebViewControl.CaptureSelectedContentToDataPackageAsync();
+
+ // Determine whether there was any selected content.
+ bool hasSelection = false;
+ try
+ {
+ hasSelection = (dp != null) && (dp.GetView().AvailableFormats.Count > 0);
+ }
+ catch (Exception ex)
+ {
+ switch (ex.HResult)
+ {
+ case unchecked((int)0x80070490):
+ // Mobile does not generate a data package with AvailableFormats
+ // and results in an exception. Sorry. Handle the case by acting as
+ // if we had no selected content.
+ hasSelection = false;
+ break;
+
+ default:
+ // All other exceptions are unexpected. Let them propagate.
+ throw;
+ }
+ }
+
+ if (hasSelection)
+ {
+ // Webview has a selection, so we'll share its data package.
+ dp.Properties.Title = "WebView sample selected content";
+ }
+ else
+ {
+ // No selection, so we'll share the url of the webview.
+ dp = new DataPackage();
+ dp.SetWebLink(WebViewControl.Source);
+ dp.Properties.Title = "WebView sample page";
+ }
+ dp.Properties.Description = WebViewControl.Source.ToString();
+ request.Data = dp;
+
+ deferral.Complete();
+ }
+ }
+}
diff --git a/Samples/XamlWebView/cs/Scenario8_CaptureBitmap.xaml b/Samples/XamlWebView/cs/Scenario8_CaptureBitmap.xaml
new file mode 100644
index 0000000000..e83254648c
--- /dev/null
+++ b/Samples/XamlWebView/cs/Scenario8_CaptureBitmap.xaml
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ Capture bitmap
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Samples/XamlWebView/cs/Scenario8_CaptureBitmap.xaml.cs b/Samples/XamlWebView/cs/Scenario8_CaptureBitmap.xaml.cs
new file mode 100644
index 0000000000..a072bbd211
--- /dev/null
+++ b/Samples/XamlWebView/cs/Scenario8_CaptureBitmap.xaml.cs
@@ -0,0 +1,89 @@
+//*********************************************************
+//
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the MIT License (MIT).
+// 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 System;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices.WindowsRuntime;
+using System.Threading.Tasks;
+using Windows.Graphics.Imaging;
+using Windows.Storage.Streams;
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Controls;
+using Windows.UI.Xaml.Media.Imaging;
+using Windows.UI.Xaml.Navigation;
+
+namespace SDKTemplate
+{
+ public sealed partial class Scenario8_CaptureBitmap : Page
+ {
+ public Scenario8_CaptureBitmap()
+ {
+ this.InitializeComponent();
+ }
+
+ protected override void OnNavigatedTo(NavigationEventArgs e)
+ {
+ WebViewControl.Navigate(new Uri("http://www.bing.com"));
+ }
+
+ ///
+ /// Captures the WebView into a bitmap.
+ ///
+ ///
+ ///
+ private async void CaptureButton_Click()
+ {
+ InMemoryRandomAccessStream stream = new InMemoryRandomAccessStream();
+ await WebViewControl.CapturePreviewToStreamAsync(stream);
+
+ // Scale the bitmap to the space available for the thumbnail image,
+ // preserving aspect ratio.
+ double thumbnailWidth = ThumbnailImage.Width;
+ double thumbnailHeight = ThumbnailImage.Height;
+ double webViewControlWidth = WebViewControl.ActualWidth;
+ double webViewControlHeight = WebViewControl.ActualHeight;
+ if (thumbnailWidth == 0 || thumbnailHeight == 0 ||
+ webViewControlWidth == 0 || webViewControlHeight == 0)
+ {
+ // Avoid 0x0 bitmaps, which cause all sorts of problems.
+ return;
+ }
+
+ double horizontalScale = thumbnailWidth / webViewControlWidth;
+ double verticalScale = thumbnailHeight / webViewControlHeight;
+ double scale = Math.Min(horizontalScale, verticalScale);
+ int width = (int)(webViewControlWidth * scale);
+ int height = (int)(webViewControlHeight * scale);
+ BitmapSource thumbnailBitmap = await CreateScaledBitmapFromStreamAsync(width, height, stream);
+
+ ThumbnailImage.Source = thumbnailBitmap;
+ }
+
+ static async Task CreateScaledBitmapFromStreamAsync(int width, int height, IRandomAccessStream source)
+ {
+ WriteableBitmap bitmap = new WriteableBitmap(width, height);
+ BitmapDecoder decoder = await BitmapDecoder.CreateAsync(source);
+ BitmapTransform transform = new BitmapTransform();
+ transform.ScaledHeight = (uint)height;
+ transform.ScaledWidth = (uint)width;
+ PixelDataProvider pixelData = await decoder.GetPixelDataAsync(
+ BitmapPixelFormat.Bgra8,
+ BitmapAlphaMode.Straight,
+ transform,
+ ExifOrientationMode.RespectExifOrientation,
+ ColorManagementMode.DoNotColorManage);
+ pixelData.DetachPixelData().CopyTo(bitmap.PixelBuffer);
+ return bitmap;
+ }
+ }
+}
diff --git a/Samples/XamlWebView/cs/Scenario9_ContainsFullScreenElement.xaml b/Samples/XamlWebView/cs/Scenario9_ContainsFullScreenElement.xaml
new file mode 100644
index 0000000000..dbd51d296c
--- /dev/null
+++ b/Samples/XamlWebView/cs/Scenario9_ContainsFullScreenElement.xaml
@@ -0,0 +1,42 @@
+
+
+
+
+
+
+
+
+
+
+
+ Full-screen mode
+
+
+ The app can respond to requests from the WebView to offer a full-screen experience.
+ For example, it may resize the WebView to occupy the entirety of the app view, or, as this
+ scenario illustrates, put a windowed app in full screen mode.
+
+
+
+
+
+
+
+
diff --git a/Samples/XamlWebView/cs/Scenario9_ContainsFullScreenElement.xaml.cs b/Samples/XamlWebView/cs/Scenario9_ContainsFullScreenElement.xaml.cs
new file mode 100644
index 0000000000..7cdd5337de
--- /dev/null
+++ b/Samples/XamlWebView/cs/Scenario9_ContainsFullScreenElement.xaml.cs
@@ -0,0 +1,51 @@
+//*********************************************************
+//
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the MIT License (MIT).
+// 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 System;
+using Windows.UI.ViewManagement;
+using Windows.UI.Xaml.Controls;
+using Windows.UI.Xaml.Navigation;
+
+namespace SDKTemplate
+{
+ ///
+ /// An empty page that can be used on its own or navigated to within a Frame.
+ ///
+ public sealed partial class Scenario9_ContainsFullScreenElement : Page
+ {
+ public Scenario9_ContainsFullScreenElement()
+ {
+ this.InitializeComponent();
+ }
+
+ protected override void OnNavigatedTo(NavigationEventArgs e)
+ {
+ WebViewControl.Navigate(new Uri("https://www.youtube.com/watch?v=XVfOe5mFbAE"));
+ }
+
+ private void WebViewControl_ContainsFullScreenElementChanged(WebView sender, object args)
+ {
+ var applicationView = ApplicationView.GetForCurrentView();
+
+ if (sender.ContainsFullScreenElement)
+ {
+ applicationView.TryEnterFullScreenMode();
+ }
+ else
+ {
+ // It is harmless to exit full screen mode when not full screen.
+ applicationView.ExitFullScreenMode();
+ }
+
+ }
+
+ }
+}
diff --git a/Samples/XamlWebView/cs/XamlWebView.csproj b/Samples/XamlWebView/cs/XamlWebView.csproj
new file mode 100644
index 0000000000..64f6c524c5
--- /dev/null
+++ b/Samples/XamlWebView/cs/XamlWebView.csproj
@@ -0,0 +1,241 @@
+
+
+
+
+ Debug
+ x86
+ {DC30CE66-DAEE-4CCF-BD02-8837FE918B6F}
+ AppContainerExe
+ Properties
+ SDKTemplate
+ XamlWebView
+ en-US
+ UAP
+ 10.0.10240.0
+ 10.0.10240.0
+ 14
+ true
+ 512
+ {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+
+
+ true
+ bin\ARM\Debug\
+ DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
+ ;2008
+ full
+ ARM
+ false
+ prompt
+ true
+
+
+ bin\ARM\Release\
+ TRACE;NETFX_CORE;WINDOWS_UWP
+ true
+ ;2008
+ pdbonly
+ ARM
+ false
+ prompt
+ true
+ true
+
+
+ true
+ bin\x64\Debug\
+ DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
+ ;2008
+ full
+ x64
+ false
+ prompt
+ true
+
+
+ bin\x64\Release\
+ TRACE;NETFX_CORE;WINDOWS_UWP
+ true
+ ;2008
+ pdbonly
+ x64
+ false
+ prompt
+ true
+ true
+
+
+ true
+ bin\x86\Debug\
+ DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
+ ;2008
+ full
+ x86
+ false
+ prompt
+ true
+
+
+ bin\x86\Release\
+ TRACE;NETFX_CORE;WINDOWS_UWP
+ true
+ ;2008
+ pdbonly
+ x86
+ false
+ prompt
+ true
+ true
+
+
+
+
+
+
+ App.xaml.cs
+ App.xaml
+
+
+ MainPage.xaml.cs
+ MainPage.xaml
+
+
+ Properties\AssemblyInfo.cs
+
+
+
+ Scenario10_UnviewableContent.xaml
+
+
+ Scenario3_InvokeScript.xaml
+
+
+ Scenario2_NavToString.xaml
+
+
+ Scenario1_NavToUrl.xaml
+
+
+ Scenario5_NavToFiles.xaml
+
+
+ Scenario4_ScriptNotify.xaml
+
+
+ Scenario6_NavToStream.xaml
+
+
+ Scenario7_Share.xaml
+
+
+ Scenario8_CaptureBitmap.xaml
+
+
+ Scenario9_ContainsFullScreenElement.xaml
+
+
+
+
+ Designer
+
+
+
+
+ App.xaml
+ MSBuild:Compile
+ Designer
+
+
+ MainPage.xaml
+ MSBuild:Compile
+ Designer
+
+
+ Designer
+ MSBuild:Compile
+
+
+ MSBuild:Compile
+ Designer
+
+
+ Designer
+ MSBuild:Compile
+
+
+ MSBuild:Compile
+ Designer
+
+
+ Designer
+ MSBuild:Compile
+
+
+ MSBuild:Compile
+ Designer
+
+
+ Styles\Styles.xaml
+ MSBuild:Compile
+ Designer
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+
+
+ Properties\Default.rd.xml
+
+
+ Assets\microsoft-sdk.png
+
+
+ Assets\smallTile-sdk.png
+
+
+ Assets\splash-sdk.png
+
+
+ Assets\squareTile-sdk.png
+
+
+ Assets\storeLogo-sdk.png
+
+
+ Assets\tile-sdk.png
+
+
+ Assets\windows-sdk.png
+
+
+
+
+
+
+
+
+ 14.0
+
+
+
+
\ No newline at end of file
diff --git a/Samples/XamlWebView/cs/XamlWebView.sln b/Samples/XamlWebView/cs/XamlWebView.sln
new file mode 100644
index 0000000000..c56eba3c37
--- /dev/null
+++ b/Samples/XamlWebView/cs/XamlWebView.sln
@@ -0,0 +1,40 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 14
+VisualStudioVersion = 14.0.23107.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XamlWebView", "XamlWebView.csproj", "{DC30CE66-DAEE-4CCF-BD02-8837FE918B6F}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|ARM = Debug|ARM
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|ARM = Release|ARM
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {DC30CE66-DAEE-4CCF-BD02-8837FE918B6F}.Debug|ARM.ActiveCfg = Debug|ARM
+ {DC30CE66-DAEE-4CCF-BD02-8837FE918B6F}.Debug|ARM.Build.0 = Debug|ARM
+ {DC30CE66-DAEE-4CCF-BD02-8837FE918B6F}.Debug|ARM.Deploy.0 = Debug|ARM
+ {DC30CE66-DAEE-4CCF-BD02-8837FE918B6F}.Debug|x64.ActiveCfg = Debug|x64
+ {DC30CE66-DAEE-4CCF-BD02-8837FE918B6F}.Debug|x64.Build.0 = Debug|x64
+ {DC30CE66-DAEE-4CCF-BD02-8837FE918B6F}.Debug|x64.Deploy.0 = Debug|x64
+ {DC30CE66-DAEE-4CCF-BD02-8837FE918B6F}.Debug|x86.ActiveCfg = Debug|x86
+ {DC30CE66-DAEE-4CCF-BD02-8837FE918B6F}.Debug|x86.Build.0 = Debug|x86
+ {DC30CE66-DAEE-4CCF-BD02-8837FE918B6F}.Debug|x86.Deploy.0 = Debug|x86
+ {DC30CE66-DAEE-4CCF-BD02-8837FE918B6F}.Release|ARM.ActiveCfg = Release|ARM
+ {DC30CE66-DAEE-4CCF-BD02-8837FE918B6F}.Release|ARM.Build.0 = Release|ARM
+ {DC30CE66-DAEE-4CCF-BD02-8837FE918B6F}.Release|ARM.Deploy.0 = Release|ARM
+ {DC30CE66-DAEE-4CCF-BD02-8837FE918B6F}.Release|x64.ActiveCfg = Release|x64
+ {DC30CE66-DAEE-4CCF-BD02-8837FE918B6F}.Release|x64.Build.0 = Release|x64
+ {DC30CE66-DAEE-4CCF-BD02-8837FE918B6F}.Release|x64.Deploy.0 = Release|x64
+ {DC30CE66-DAEE-4CCF-BD02-8837FE918B6F}.Release|x86.ActiveCfg = Release|x86
+ {DC30CE66-DAEE-4CCF-BD02-8837FE918B6F}.Release|x86.Build.0 = Release|x86
+ {DC30CE66-DAEE-4CCF-BD02-8837FE918B6F}.Release|x86.Deploy.0 = Release|x86
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/Samples/XamlWebView/cs/html/html_example.html b/Samples/XamlWebView/cs/html/html_example.html
new file mode 100644
index 0000000000..f9b41f511a
--- /dev/null
+++ b/Samples/XamlWebView/cs/html/html_example.html
@@ -0,0 +1,9 @@
+
+
+ Example HTML document
+
+ Hi!
+ This is a very simple HTML page.
+ This content will be show in the WebView control when you click the button.
+
+
diff --git a/Samples/XamlWebView/cs/html/html_example2.html b/Samples/XamlWebView/cs/html/html_example2.html
new file mode 100644
index 0000000000..c1558d9d11
--- /dev/null
+++ b/Samples/XamlWebView/cs/html/html_example2.html
@@ -0,0 +1,16 @@
+
+
+
+ Example HTML document
+
+
+
+ This is a very simple HTML page.
+ According to the browser DOM, this content has been loaded from .
+
+
+
diff --git a/Samples/XamlWebView/cs/html/scriptNotify_example.html b/Samples/XamlWebView/cs/html/scriptNotify_example.html
new file mode 100644
index 0000000000..0e619f0654
--- /dev/null
+++ b/Samples/XamlWebView/cs/html/scriptNotify_example.html
@@ -0,0 +1,9 @@
+
+
+
+ This is a simple test page for window.external.notify().
+
+ Call window.external.notify
+
+
+
diff --git a/Samples/XamlWebView/cs/html/script_example.html b/Samples/XamlWebView/cs/html/script_example.html
new file mode 100644
index 0000000000..e11f43948a
--- /dev/null
+++ b/Samples/XamlWebView/cs/html/script_example.html
@@ -0,0 +1,14 @@
+
+
+
+
+
+ Hello
+
+
diff --git a/Samples/XamlWebView/cs/html/stream_example.html b/Samples/XamlWebView/cs/html/stream_example.html
new file mode 100644
index 0000000000..d4fe8b1b6a
--- /dev/null
+++ b/Samples/XamlWebView/cs/html/stream_example.html
@@ -0,0 +1,14 @@
+
+
+
+ Streamed content
+
+
+
+
+ This page was streamed by %.
+
+
+
+
+
diff --git a/Samples/XamlWebView/cs/project.json b/Samples/XamlWebView/cs/project.json
new file mode 100644
index 0000000000..c594939270
--- /dev/null
+++ b/Samples/XamlWebView/cs/project.json
@@ -0,0 +1,16 @@
+{
+ "dependencies": {
+ "Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0"
+ },
+ "frameworks": {
+ "uap10.0": {}
+ },
+ "runtimes": {
+ "win10-arm": {},
+ "win10-arm-aot": {},
+ "win10-x86": {},
+ "win10-x86-aot": {},
+ "win10-x64": {},
+ "win10-x64-aot": {}
+ }
+}
\ No newline at end of file