diff --git a/README.md b/README.md
index 25803a3503..99b97ccba9 100644
--- a/README.md
+++ b/README.md
@@ -225,11 +225,12 @@ For additional Windows samples, see [Windows on GitHub](http://microsoft.github.
Logging
+ PDF document
Serializing and deserializing data
x:Bind
- x:DeferLoadStrategy
+ x:DeferLoadStrategy
XML DOM
XmlLite
@@ -387,19 +388,20 @@ For additional Windows samples, see [Windows on GitHub](http://microsoft.github.
Credential locker
Credential picker
- Disabling screen capture
+ Device lockdown with Azure login
+ Disabling screen capture
Enterprise data protection
KeyCredentialManager
- Lock screen personalization
+ Lock screen personalization
Smart cards
User information
- UserConsentVerifier
+ UserConsentVerifier
Web account management
WebAuthenticationBroker
diff --git a/Samples/Accelerometer/README.md b/Samples/Accelerometer/README.md
index 6cbb881e5f..a42a7dbeb5 100644
--- a/Samples/Accelerometer/README.md
+++ b/Samples/Accelerometer/README.md
@@ -1,6 +1,6 @@
# Accelerometer sample
diff --git a/Samples/ActivitySensor/README.md b/Samples/ActivitySensor/README.md
index 181035ea44..b21974df4d 100644
--- a/Samples/ActivitySensor/README.md
+++ b/Samples/ActivitySensor/README.md
@@ -1,6 +1,6 @@
# Activity detection sensor sample
diff --git a/Samples/AdaptiveStreaming/README.md b/Samples/AdaptiveStreaming/README.md
index 34c11ad411..3b17944a0c 100644
--- a/Samples/AdaptiveStreaming/README.md
+++ b/Samples/AdaptiveStreaming/README.md
@@ -1,6 +1,6 @@
# Adaptive streaming sample
diff --git a/Samples/AdvancedCasting/README.md b/Samples/AdvancedCasting/README.md
index ea798f7e26..b0a43c2f35 100644
--- a/Samples/AdvancedCasting/README.md
+++ b/Samples/AdvancedCasting/README.md
@@ -1,6 +1,6 @@
# Advanced casting sample
diff --git a/Samples/AllJoyn/ConsumerExperiences/README.md b/Samples/AllJoyn/ConsumerExperiences/README.md
index e8770b317e..cff5247643 100644
--- a/Samples/AllJoyn/ConsumerExperiences/README.md
+++ b/Samples/AllJoyn/ConsumerExperiences/README.md
@@ -1,6 +1,6 @@
# AllJoyn consumer experiences sample
diff --git a/Samples/AllJoyn/ProducerExperiences/README.md b/Samples/AllJoyn/ProducerExperiences/README.md
index 6682d866a4..14ba77ef05 100644
--- a/Samples/AllJoyn/ProducerExperiences/README.md
+++ b/Samples/AllJoyn/ProducerExperiences/README.md
@@ -1,6 +1,6 @@
# AllJoyn producer experiences sample
diff --git a/Samples/Altimeter/README.md b/Samples/Altimeter/README.md
index dcd6d32bbd..13393d0c70 100644
--- a/Samples/Altimeter/README.md
+++ b/Samples/Altimeter/README.md
@@ -1,6 +1,6 @@
# Altimeter sample
diff --git a/Samples/AnimationLibrary/README.md b/Samples/AnimationLibrary/README.md
index 3a06870a10..32846bdd84 100644
--- a/Samples/AnimationLibrary/README.md
+++ b/Samples/AnimationLibrary/README.md
@@ -1,6 +1,6 @@
# Animation library (HTML) sample
diff --git a/Samples/AnimationLibrary/js/html/samplePage.html b/Samples/AnimationLibrary/js/html/samplePage.html
index b9cc4031c3..1809880904 100644
--- a/Samples/AnimationLibrary/js/html/samplePage.html
+++ b/Samples/AnimationLibrary/js/html/samplePage.html
@@ -24,7 +24,6 @@
ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent
luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Typi non habent claritatem insitam; est
usus legentis in iis qui facit eorum claritatem.
- Click to return
diff --git a/Samples/AnimationLibrary/js/js/samplePage.js b/Samples/AnimationLibrary/js/js/samplePage.js
index 2ac2e5c55d..14c327fe5c 100644
--- a/Samples/AnimationLibrary/js/js/samplePage.js
+++ b/Samples/AnimationLibrary/js/js/samplePage.js
@@ -3,22 +3,23 @@
(function () {
"use strict";
+ var systemNavigationManager = Windows.UI.Core.SystemNavigationManager.getForCurrentView();
+
WinJS.UI.Pages.define("/html/samplePage.html", {
ready: function (element, options) {
- returnButton.addEventListener("click", transitionBetweenPages, false);
-// rootGrid.style.overflow= "auto";
-// content.style.overflow = "visible";
+ systemNavigationManager.addEventListener("backrequested", backRequested);
+ systemNavigationManager.appViewBackButtonVisibility = Windows.UI.Core.AppViewBackButtonVisibility.visible;
// Run enter page animation to animate in the page that has just been loaded
WinJS.UI.Animation.enterPage([samplePageHeader, samplePageSection1, samplePageSection2], null);
},
unload: function () {
-// rootGrid.style.overflow = "visible";
-// content.style.overflow = "auto";
+ systemNavigationManager.removeEventListener("backrequested", backRequested);
+ systemNavigationManager.appViewBackButtonVisibility = Windows.UI.Core.AppViewBackButtonVisibility.collapsed;
}
});
- function transitionBetweenPages() {
+ function backRequested() {
// When navigating away from this page, run exit page animation on current page, then navigate to new page
WinJS.UI.Animation.exitPage([samplePageHeader, samplePageSection1, samplePageSection2], null).done(
function () {
diff --git a/Samples/AnimationMetrics/README.md b/Samples/AnimationMetrics/README.md
index 7a2a40fb4f..45f9c24568 100644
--- a/Samples/AnimationMetrics/README.md
+++ b/Samples/AnimationMetrics/README.md
@@ -1,6 +1,6 @@
# Animation metrics sample
diff --git a/Samples/AppServices/README.md b/Samples/AppServices/README.md
index 932df93ccb..007003b88e 100644
--- a/Samples/AppServices/README.md
+++ b/Samples/AppServices/README.md
@@ -1,6 +1,6 @@
# App services sample
diff --git a/Samples/ApplicationData/README.md b/Samples/ApplicationData/README.md
index 1a8874d6cb..3ac3800dd6 100644
--- a/Samples/ApplicationData/README.md
+++ b/Samples/ApplicationData/README.md
@@ -1,6 +1,6 @@
# Application data sample
diff --git a/Samples/ApplicationResources/README.md b/Samples/ApplicationResources/README.md
index 4b09c6d298..5065a3d6ad 100644
--- a/Samples/ApplicationResources/README.md
+++ b/Samples/ApplicationResources/README.md
@@ -1,6 +1,6 @@
# Application resources and localization sample
diff --git a/Samples/Appointments/README.md b/Samples/Appointments/README.md
index 808b205d57..5429149713 100644
--- a/Samples/Appointments/README.md
+++ b/Samples/Appointments/README.md
@@ -1,6 +1,6 @@
# Appointment calendar sample
diff --git a/Samples/AssociationLaunching/README.md b/Samples/AssociationLaunching/README.md
index 3334bb63e1..7062b4572c 100644
--- a/Samples/AssociationLaunching/README.md
+++ b/Samples/AssociationLaunching/README.md
@@ -1,6 +1,6 @@
# Association launching sample
diff --git a/Samples/AudioCategory/README.md b/Samples/AudioCategory/README.md
index 22ef40a5ca..b6c509a3af 100644
--- a/Samples/AudioCategory/README.md
+++ b/Samples/AudioCategory/README.md
@@ -1,6 +1,6 @@
# Audio categories sample
diff --git a/Samples/AudioCreation/README.md b/Samples/AudioCreation/README.md
index 760ba7ccd0..a557497401 100644
--- a/Samples/AudioCreation/README.md
+++ b/Samples/AudioCreation/README.md
@@ -1,6 +1,6 @@
# AudioGraph sample
diff --git a/Samples/BackButton/README.md b/Samples/BackButton/README.md
index fb4b777c8c..b96602844f 100644
--- a/Samples/BackButton/README.md
+++ b/Samples/BackButton/README.md
@@ -1,6 +1,6 @@
# Back Button Sample
diff --git a/Samples/BackgroundAudio/README.md b/Samples/BackgroundAudio/README.md
index aeedbb3dd1..e381d25987 100644
--- a/Samples/BackgroundAudio/README.md
+++ b/Samples/BackgroundAudio/README.md
@@ -1,6 +1,6 @@
# Background audio sample
diff --git a/Samples/BackgroundAudio/cs/BackgroundAudio/Scenario1.xaml.cs b/Samples/BackgroundAudio/cs/BackgroundAudio/Scenario1.xaml.cs
index 1288991246..7d205116e1 100644
--- a/Samples/BackgroundAudio/cs/BackgroundAudio/Scenario1.xaml.cs
+++ b/Samples/BackgroundAudio/cs/BackgroundAudio/Scenario1.xaml.cs
@@ -39,7 +39,7 @@ public sealed partial class Scenario1 : Page
#region Private Fields and Properties
private MainPage rootPage;
private AutoResetEvent backgroundAudioTaskStarted;
- private bool isMyBackgroundTaskRunning = false;
+ private bool _isMyBackgroundTaskRunning = false;
private Dictionary albumArtCache = new Dictionary();
const int RPC_S_SERVER_UNAVAILABLE = -2147023174; // 0x800706BA
@@ -52,7 +52,7 @@ private bool IsMyBackgroundTaskRunning
{
get
{
- if (isMyBackgroundTaskRunning)
+ if (_isMyBackgroundTaskRunning)
return true;
string value = ApplicationSettingsHelper.ReadResetSettingsValue(ApplicationSettingsConstants.BackgroundTaskState) as string;
@@ -64,13 +64,13 @@ private bool IsMyBackgroundTaskRunning
{
try
{
- isMyBackgroundTaskRunning = EnumHelper.Parse(value) == BackgroundTaskState.Running;
+ _isMyBackgroundTaskRunning = EnumHelper.Parse(value) == BackgroundTaskState.Running;
}
catch(ArgumentException)
{
- isMyBackgroundTaskRunning = false;
+ _isMyBackgroundTaskRunning = false;
}
- return isMyBackgroundTaskRunning;
+ return _isMyBackgroundTaskRunning;
}
}
}
@@ -87,20 +87,28 @@ private MediaPlayer CurrentPlayer
get
{
MediaPlayer mp = null;
+ int retryCount = 2;
- try
+ while (mp == null && --retryCount >= 0)
{
- mp = BackgroundMediaPlayer.Current;
- }
- catch (Exception ex)
- {
- if (ex.HResult == RPC_S_SERVER_UNAVAILABLE)
+ try
{
- // The foreground app uses RPC to communicate with the background process.
- // If the background process crashes or is killed for any reason RPC_S_SERVER_UNAVAILABLE
- // is returned when calling Current.
- ResetAfterLostBackground();
- StartBackgroundAudioTask();
+ mp = BackgroundMediaPlayer.Current;
+ }
+ catch (Exception ex)
+ {
+ if (ex.HResult == RPC_S_SERVER_UNAVAILABLE)
+ {
+ // The foreground app uses RPC to communicate with the background process.
+ // If the background process crashes or is killed for any reason RPC_S_SERVER_UNAVAILABLE
+ // is returned when calling Current. We must restart the task, the while loop will retry to set mp.
+ ResetAfterLostBackground();
+ StartBackgroundAudioTask();
+ }
+ else
+ {
+ throw;
+ }
}
}
@@ -114,12 +122,13 @@ private MediaPlayer CurrentPlayer
}
///
- /// The background task did exist, but it has disappeared. Put the foreground back into an initial state.
+ /// The background task did exist, but it has disappeared. Put the foreground back into an initial state. Unfortunately,
+ /// any attempts to unregister things on BackgroundMediaPlayer.Current will fail with the RPC error once the background task has been lost.
///
private void ResetAfterLostBackground()
{
BackgroundMediaPlayer.Shutdown();
- isMyBackgroundTaskRunning = false;
+ _isMyBackgroundTaskRunning = false;
backgroundAudioTaskStarted.Reset();
prevButton.IsEnabled = true;
nextButton.IsEnabled = true;
@@ -136,6 +145,10 @@ private void ResetAfterLostBackground()
{
throw new Exception("Failed to get a MediaPlayer instance.");
}
+ else
+ {
+ throw;
+ }
}
}
@@ -220,7 +233,7 @@ protected override void OnNavigatedTo(NavigationEventArgs e)
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
- if(isMyBackgroundTaskRunning)
+ if(_isMyBackgroundTaskRunning)
{
RemoveMediaPlayerEventHandlers();
ApplicationSettingsHelper.SaveSettingsValue(ApplicationSettingsConstants.BackgroundTaskState, BackgroundTaskState.Running.ToString());
@@ -500,9 +513,9 @@ private void UpdateTransportControls(MediaPlayerState state)
///
private void RemoveMediaPlayerEventHandlers()
{
- CurrentPlayer.CurrentStateChanged -= this.MediaPlayer_CurrentStateChanged;
try
{
+ BackgroundMediaPlayer.Current.CurrentStateChanged -= this.MediaPlayer_CurrentStateChanged;
BackgroundMediaPlayer.MessageReceivedFromBackground -= BackgroundMediaPlayer_MessageReceivedFromBackground;
}
catch (Exception ex)
@@ -536,6 +549,10 @@ private void AddMediaPlayerEventHandlers()
// Internally MessageReceivedFromBackground calls Current which can throw RPC_S_SERVER_UNAVAILABLE
ResetAfterLostBackground();
}
+ else
+ {
+ throw;
+ }
}
}
diff --git a/Samples/BackgroundSensors/README.md b/Samples/BackgroundSensors/README.md
index 9a650d1038..4984948d1f 100644
--- a/Samples/BackgroundSensors/README.md
+++ b/Samples/BackgroundSensors/README.md
@@ -1,6 +1,6 @@
# Background sensors sample
diff --git a/Samples/BackgroundTask/README.md b/Samples/BackgroundTask/README.md
index 242ee585f7..00d222ec93 100644
--- a/Samples/BackgroundTask/README.md
+++ b/Samples/BackgroundTask/README.md
@@ -1,6 +1,6 @@
# Background task sample
diff --git a/Samples/BackgroundTransfer/README.md b/Samples/BackgroundTransfer/README.md
index d208927b96..abedbadbaa 100644
--- a/Samples/BackgroundTransfer/README.md
+++ b/Samples/BackgroundTransfer/README.md
@@ -1,6 +1,6 @@
# Background transfer sample
diff --git a/Samples/BarcodeScanner/README.md b/Samples/BarcodeScanner/README.md
index b058f123ae..a29e2d597d 100644
--- a/Samples/BarcodeScanner/README.md
+++ b/Samples/BarcodeScanner/README.md
@@ -1,6 +1,6 @@
# Barcode scanner sample
diff --git a/Samples/Barometer/README.md b/Samples/Barometer/README.md
index 144815c606..b389da32de 100644
--- a/Samples/Barometer/README.md
+++ b/Samples/Barometer/README.md
@@ -1,6 +1,6 @@
# Barometer sample
diff --git a/Samples/BasicFaceDetection/README.md b/Samples/BasicFaceDetection/README.md
index 1bbe97b9f1..501506e7ef 100644
--- a/Samples/BasicFaceDetection/README.md
+++ b/Samples/BasicFaceDetection/README.md
@@ -1,6 +1,6 @@
# Basic face detection sample
diff --git a/Samples/BasicFaceTracking/README.md b/Samples/BasicFaceTracking/README.md
index 0f2e028e6f..0f23f3fbd0 100644
--- a/Samples/BasicFaceTracking/README.md
+++ b/Samples/BasicFaceTracking/README.md
@@ -1,6 +1,6 @@
# Basic face tracking sample
diff --git a/Samples/BasicInput/README.md b/Samples/BasicInput/README.md
index acf5f437b6..0ac9eaadd4 100644
--- a/Samples/BasicInput/README.md
+++ b/Samples/BasicInput/README.md
@@ -1,6 +1,6 @@
# Basic input sample
diff --git a/Samples/BasicMediaCasting/README.md b/Samples/BasicMediaCasting/README.md
index 3deefcd96e..425d59faf3 100644
--- a/Samples/BasicMediaCasting/README.md
+++ b/Samples/BasicMediaCasting/README.md
@@ -1,6 +1,6 @@
# Basic media casting sample
diff --git a/Samples/BluetoothAdvertisement/README.md b/Samples/BluetoothAdvertisement/README.md
index 5b79bfa7be..3d5fea1948 100644
--- a/Samples/BluetoothAdvertisement/README.md
+++ b/Samples/BluetoothAdvertisement/README.md
@@ -1,6 +1,6 @@
# Bluetooth advertisement sample
diff --git a/Samples/BluetoothRfcommChat/README.md b/Samples/BluetoothRfcommChat/README.md
index e30571c7e3..c2594a3a7e 100644
--- a/Samples/BluetoothRfcommChat/README.md
+++ b/Samples/BluetoothRfcommChat/README.md
@@ -1,6 +1,6 @@
# Bluetooth RFCOMM chat sample
diff --git a/Samples/Calendar/README.md b/Samples/Calendar/README.md
index 6e71bb0d22..a117e83cb9 100644
--- a/Samples/Calendar/README.md
+++ b/Samples/Calendar/README.md
@@ -1,6 +1,6 @@
# Calendar sample
diff --git a/Samples/CameraFaceDetection/README.md b/Samples/CameraFaceDetection/README.md
index c64a85e1f2..b4d6ee8bd2 100644
--- a/Samples/CameraFaceDetection/README.md
+++ b/Samples/CameraFaceDetection/README.md
@@ -1,6 +1,6 @@
# Camera face detection sample
diff --git a/Samples/CameraGetPreviewFrame/README.md b/Samples/CameraGetPreviewFrame/README.md
index a5ded7c7b1..148838539b 100644
--- a/Samples/CameraGetPreviewFrame/README.md
+++ b/Samples/CameraGetPreviewFrame/README.md
@@ -1,6 +1,6 @@
# Camera preview frame sample
diff --git a/Samples/CameraHdr/README.md b/Samples/CameraHdr/README.md
index 3220749099..89342954b1 100644
--- a/Samples/CameraHdr/README.md
+++ b/Samples/CameraHdr/README.md
@@ -1,6 +1,6 @@
# High dynamic range sample
diff --git a/Samples/CameraManualControls/README.md b/Samples/CameraManualControls/README.md
index febc74b7a2..c07f23ff47 100644
--- a/Samples/CameraManualControls/README.md
+++ b/Samples/CameraManualControls/README.md
@@ -1,6 +1,6 @@
# Manual camera controls sample
diff --git a/Samples/CameraManualControls/cs/MainPage.xaml.cs b/Samples/CameraManualControls/cs/MainPage.xaml.cs
index 8a40b9c21e..5f69d2c861 100644
--- a/Samples/CameraManualControls/cs/MainPage.xaml.cs
+++ b/Samples/CameraManualControls/cs/MainPage.xaml.cs
@@ -60,6 +60,9 @@ public sealed partial class MainPage : Page
// For listening to media property changes
private readonly SystemMediaTransportControls _systemMediaControls = SystemMediaTransportControls.GetForCurrentView();
+ // Access to the Back button
+ private readonly SystemNavigationManager _systemNavigationManager = SystemNavigationManager.GetForCurrentView();
+
// MediaCapture and its state variables
private MediaCapture _mediaCapture;
private bool _isInitialized;
@@ -608,7 +611,6 @@ private void RegisterEventHandlers()
if (ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
{
HardwareButtons.CameraPressed += HardwareButtons_CameraPressed;
- HardwareButtons.BackPressed += HardwareButtons_BackPressed;
}
// If there is an orientation sensor present on the device, register for notifications
@@ -622,32 +624,21 @@ private void RegisterEventHandlers()
_displayInformation.OrientationChanged += DisplayInformation_OrientationChanged;
_systemMediaControls.PropertyChanged += SystemMediaControls_PropertyChanged;
+ _systemNavigationManager.BackRequested += SystemNavigationManager_BackRequested;
}
- private void HardwareButtons_BackPressed(object sender, BackPressedEventArgs e)
+ private void SystemNavigationManager_BackRequested(object sender, BackRequestedEventArgs e)
{
- // Back button exits single control mode
if (_singleControlMode)
{
// Exit single control mode
- _singleControlMode = false;
-
- // If in single control mode, hide all child buttons (except for the sender). Otherwise show all buttons.
- foreach (var button in ScenarioControlStackPanel.Children)
- {
- if (button is Button && button != sender)
- {
- button.Visibility = Visibility.Visible;
- }
- }
-
- // Hide the container control for manual input
- ManualControlsGrid.Visibility = Visibility.Collapsed;
+ SetSingleControl(null);
e.Handled = true;
}
}
+
///
/// Unregisters event handlers for hardware buttons and orientation sensors
///
@@ -656,7 +647,6 @@ private void UnregisterEventHandlers()
if (ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
{
HardwareButtons.CameraPressed -= HardwareButtons_CameraPressed;
- HardwareButtons.BackPressed -= HardwareButtons_BackPressed;
}
if (_orientationSensor != null)
@@ -666,6 +656,7 @@ private void UnregisterEventHandlers()
_displayInformation.OrientationChanged -= DisplayInformation_OrientationChanged;
_systemMediaControls.PropertyChanged -= SystemMediaControls_PropertyChanged;
+ _systemNavigationManager.BackRequested -= SystemNavigationManager_BackRequested;
}
///
@@ -912,24 +903,35 @@ private void UpdateButtonOrientation()
#region Manual controls setup
- private void ManualControlButton_Tapped(object sender, TappedRoutedEventArgs e)
+ // If activeButton = null, then exit single control mode.
+ private void SetSingleControl(object activeButton)
{
- // Toggle single control mode
- _singleControlMode = !_singleControlMode;
+ _singleControlMode = (activeButton != null);
- // If in single control mode, hide all manual control buttons (except for the sender, which was tapped), otherwise show all buttons
- foreach (var button in ScenarioControlStackPanel.Children)
+ // If in single control mode, hide all manual control buttons (except for the active button).
+ // if not in single control mode, then show all the buttons which are supported.
+ foreach (var button in ScenarioControlStackPanel.Children.OfType())
{
- if (button is Button && button != sender)
+ if (button != activeButton)
{
- // The Tag property of each button stores whether that button should be displayed or not, which depends on whether the control is supported or not
- // The value is set in the Update___ControlCapabilities method of each control
- button.Visibility = _singleControlMode ? Visibility.Collapsed : (Visibility)(button as Button).Tag;
+ // The Tag property of each button stores whether that button is supported.
+ // The value is set in the Update___ControlCapabilities method of each control.
+ button.Visibility = _singleControlMode ? Visibility.Collapsed : (Visibility)button.Tag;
}
}
// Show the container control for manual configuration only when in single control mode
ManualControlsGrid.Visibility = _singleControlMode ? Visibility.Visible : Visibility.Collapsed;
+
+ // Show the Back button only when in single control mode
+ _systemNavigationManager.AppViewBackButtonVisibility = _singleControlMode ? AppViewBackButtonVisibility.Visible : AppViewBackButtonVisibility.Collapsed;
+
+ }
+
+ private void ManualControlButton_Tapped(object sender, TappedRoutedEventArgs e)
+ {
+ // Toggle single control mode
+ SetSingleControl(_singleControlMode ? null : sender);
}
///
diff --git a/Samples/CameraProfile/README.md b/Samples/CameraProfile/README.md
index 2c7a622d91..b907c1890c 100644
--- a/Samples/CameraProfile/README.md
+++ b/Samples/CameraProfile/README.md
@@ -1,6 +1,6 @@
# Camera profiles sample
diff --git a/Samples/CameraResolution/README.md b/Samples/CameraResolution/README.md
index f56c4c172d..b0dd2262b7 100644
--- a/Samples/CameraResolution/README.md
+++ b/Samples/CameraResolution/README.md
@@ -1,6 +1,6 @@
# Camera resolution sample
diff --git a/Samples/CameraResolution/cpp/StreamResolutionHelper.cpp b/Samples/CameraResolution/cpp/StreamResolutionHelper.cpp
index c0128d4ae0..a5dd63ab47 100644
--- a/Samples/CameraResolution/cpp/StreamResolutionHelper.cpp
+++ b/Samples/CameraResolution/cpp/StreamResolutionHelper.cpp
@@ -84,7 +84,10 @@ unsigned int StreamResolutionHelper::FrameRate()
if (_type == VIDEO_ENCODING_STRING)
{
VideoEncodingProperties^ videoEncodingProperties = static_cast(_encodingProperties);
- return videoEncodingProperties->FrameRate->Numerator / videoEncodingProperties->FrameRate->Denominator;
+ if (videoEncodingProperties->FrameRate->Denominator != 0)
+ {
+ return videoEncodingProperties->FrameRate->Numerator / videoEncodingProperties->FrameRate->Denominator;
+ }
}
return 0;
diff --git a/Samples/CameraResolution/cs/StreamResolution.cs b/Samples/CameraResolution/cs/StreamResolution.cs
index 28e8dbc927..66ba6b0b72 100644
--- a/Samples/CameraResolution/cs/StreamResolution.cs
+++ b/Samples/CameraResolution/cs/StreamResolution.cs
@@ -80,7 +80,10 @@ public uint FrameRate
{
if (_properties is VideoEncodingProperties)
{
- return (_properties as VideoEncodingProperties).FrameRate.Numerator / (_properties as VideoEncodingProperties).FrameRate.Denominator;
+ if ((_properties as VideoEncodingProperties).FrameRate.Denominator != 0)
+ {
+ return (_properties as VideoEncodingProperties).FrameRate.Numerator / (_properties as VideoEncodingProperties).FrameRate.Denominator;
+ }
}
return 0;
diff --git a/Samples/CameraResolution/js/js/StreamResolutionHelper.js b/Samples/CameraResolution/js/js/StreamResolutionHelper.js
index d20f3e5c87..10f5b9366e 100644
--- a/Samples/CameraResolution/js/js/StreamResolutionHelper.js
+++ b/Samples/CameraResolution/js/js/StreamResolutionHelper.js
@@ -50,7 +50,9 @@ streamResolutionHelper.prototype.height = function () {
streamResolutionHelper.prototype.frameRate = function () {
if (this.encodingProperties.type === "Video") {
- return Math.round(this.encodingProperties.frameRate.numerator / this.encodingProperties.frameRate.denominator);
+ if (this.encodingProperties.frameRate.denominator != 0) {
+ return Math.round(this.encodingProperties.frameRate.numerator / this.encodingProperties.frameRate.denominator);
+ }
}
return 0;
diff --git a/Samples/CameraStarterKit/README.md b/Samples/CameraStarterKit/README.md
index 1722c8dab5..d50e2313ec 100644
--- a/Samples/CameraStarterKit/README.md
+++ b/Samples/CameraStarterKit/README.md
@@ -1,6 +1,6 @@
# Basic camera app sample
diff --git a/Samples/CameraVideoStabilization/README.md b/Samples/CameraVideoStabilization/README.md
index f51cedb19d..44c3fda6fd 100644
--- a/Samples/CameraVideoStabilization/README.md
+++ b/Samples/CameraVideoStabilization/README.md
@@ -1,6 +1,6 @@
# Video stabilization sample
diff --git a/Samples/CashDrawer/README.md b/Samples/CashDrawer/README.md
index 7e89865046..5678087a62 100644
--- a/Samples/CashDrawer/README.md
+++ b/Samples/CashDrawer/README.md
@@ -1,6 +1,6 @@
# Cash drawer sample
diff --git a/Samples/Clipboard/README.md b/Samples/Clipboard/README.md
index 1bbd09121f..7352dd40f1 100644
--- a/Samples/Clipboard/README.md
+++ b/Samples/Clipboard/README.md
@@ -1,6 +1,6 @@
# Clipboard sample
diff --git a/Samples/CommunicationBlockAndFilter/README.md b/Samples/CommunicationBlockAndFilter/README.md
index a29d4785ac..39ace43272 100755
--- a/Samples/CommunicationBlockAndFilter/README.md
+++ b/Samples/CommunicationBlockAndFilter/README.md
@@ -1,6 +1,6 @@
# Communication blocking and filtering sample
diff --git a/Samples/Compass/README.md b/Samples/Compass/README.md
index f39459aab3..aa7c3f207e 100644
--- a/Samples/Compass/README.md
+++ b/Samples/Compass/README.md
@@ -1,6 +1,6 @@
# Compass sample
diff --git a/Samples/ComplexInk/README.md b/Samples/ComplexInk/README.md
index d0a6cf3072..f05a04d7ea 100644
--- a/Samples/ComplexInk/README.md
+++ b/Samples/ComplexInk/README.md
@@ -1,6 +1,6 @@
# Complex inking sample
diff --git a/Samples/CompositionVisual/README.md b/Samples/CompositionVisual/README.md
index 05fe479f25..7e536f4f78 100644
--- a/Samples/CompositionVisual/README.md
+++ b/Samples/CompositionVisual/README.md
@@ -1,6 +1,6 @@
# Composition visual without framework sample
diff --git a/Samples/Compression/README.md b/Samples/Compression/README.md
index 42a838d676..708c5f3431 100644
--- a/Samples/Compression/README.md
+++ b/Samples/Compression/README.md
@@ -1,6 +1,6 @@
# Compression sample
diff --git a/Samples/ContactCardIntegration/README.md b/Samples/ContactCardIntegration/README.md
index 3a5c2015d6..92935f7e12 100644
--- a/Samples/ContactCardIntegration/README.md
+++ b/Samples/ContactCardIntegration/README.md
@@ -1,5 +1,6 @@
# Contact Card integration sample
diff --git a/Samples/ContactCards/README.md b/Samples/ContactCards/README.md
index 3f1741e06c..2a1efd2e0e 100644
--- a/Samples/ContactCards/README.md
+++ b/Samples/ContactCards/README.md
@@ -1,6 +1,6 @@
# Contact cards sample
diff --git a/Samples/ContactPicker/README.md b/Samples/ContactPicker/README.md
index 2123025683..fc1ce0bf7a 100644
--- a/Samples/ContactPicker/README.md
+++ b/Samples/ContactPicker/README.md
@@ -1,6 +1,6 @@
# Contact picker sample
diff --git a/Samples/ContentIndexer/README.md b/Samples/ContentIndexer/README.md
index 39700cec81..001032a02c 100644
--- a/Samples/ContentIndexer/README.md
+++ b/Samples/ContentIndexer/README.md
@@ -1,6 +1,6 @@
# Content indexer sample
diff --git a/Samples/ContextMenu/README.md b/Samples/ContextMenu/README.md
index cb87cfdb58..851d260a99 100644
--- a/Samples/ContextMenu/README.md
+++ b/Samples/ContextMenu/README.md
@@ -1,6 +1,6 @@
# Context menu sample
diff --git a/Samples/CortanaVoiceCommand/README.md b/Samples/CortanaVoiceCommand/README.md
index bd1bb21102..9094ba9b45 100644
--- a/Samples/CortanaVoiceCommand/README.md
+++ b/Samples/CortanaVoiceCommand/README.md
@@ -1,6 +1,6 @@
# Cortana voice command sample
diff --git a/Samples/CortanaVoiceCommand/cpp/AdventureWorks/App.xaml.cpp b/Samples/CortanaVoiceCommand/cpp/AdventureWorks/App.xaml.cpp
index ad1bbc870f..efc55ad8e7 100644
--- a/Samples/CortanaVoiceCommand/cpp/AdventureWorks/App.xaml.cpp
+++ b/Samples/CortanaVoiceCommand/cpp/AdventureWorks/App.xaml.cpp
@@ -25,6 +25,7 @@ using namespace Windows::Foundation;
using namespace Windows::Foundation::Collections;
using namespace Windows::Media::SpeechRecognition;
using namespace Windows::Storage;
+using namespace Windows::UI::Core;
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Controls;
using namespace Windows::UI::Xaml::Controls::Primitives;
@@ -67,6 +68,11 @@ void App::OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEvent
rootFrame->NavigationFailed += ref new Windows::UI::Xaml::Navigation::NavigationFailedEventHandler(this, &App::OnNavigationFailed);
+ // Register for Back button events.
+ SystemNavigationManager::GetForCurrentView()->BackRequested += ref new Windows::Foundation::EventHandler(this, &App::OnBackRequested);
+
+ // Register for navigation events so we can update the Back button.
+ rootFrame->Navigated += ref new NavigatedEventHandler(this, &App::OnNavigated);
if (rootFrame->Content == nullptr)
{
@@ -236,3 +242,37 @@ void App::OnNavigationFailed(Platform::Object ^sender, Windows::UI::Xaml::Naviga
{
throw ref new FailureException("Failed to load Page " + e->SourcePageType.Name);
}
+
+void App::OnNavigated(Object^ sender, NavigationEventArgs^ args)
+{
+ bool canGoBack = false;
+ auto rootFrame = dynamic_cast (Window::Current->Content);
+ if (rootFrame != nullptr)
+ {
+ // If we returned to the root page, then empty the backstack.
+ if (rootFrame->BackStack->Size > 0 &&
+ args->SourcePageType.Name == rootFrame->BackStack->GetAt(0)->SourcePageType.Name)
+ {
+ rootFrame->BackStack->Clear();
+ }
+
+ canGoBack = rootFrame->CanGoBack;
+ }
+
+ // Set the Back button state appropriately.
+ SystemNavigationManager::GetForCurrentView()->AppViewBackButtonVisibility =
+ canGoBack ? AppViewBackButtonVisibility::Visible : AppViewBackButtonVisibility::Collapsed;
+}
+
+void App::OnBackRequested(Object^ sender, BackRequestedEventArgs^ e)
+{
+ if (!e->Handled)
+ {
+ auto rootFrame = dynamic_cast (Window::Current->Content);
+ if (rootFrame != nullptr && rootFrame->CanGoBack)
+ {
+ e->Handled = true;
+ rootFrame->GoBack();
+ }
+ }
+}
diff --git a/Samples/CortanaVoiceCommand/cpp/AdventureWorks/App.xaml.h b/Samples/CortanaVoiceCommand/cpp/AdventureWorks/App.xaml.h
index d3c79df078..701d611e69 100644
--- a/Samples/CortanaVoiceCommand/cpp/AdventureWorks/App.xaml.h
+++ b/Samples/CortanaVoiceCommand/cpp/AdventureWorks/App.xaml.h
@@ -30,6 +30,9 @@ namespace AdventureWorks
private:
void OnNavigationFailed(Platform::Object ^sender, Windows::UI::Xaml::Navigation::NavigationFailedEventArgs ^e);
+ void OnNavigated(Platform::Object^ sender, Windows::UI::Xaml::Navigation::NavigationEventArgs^ e);
+ void OnBackRequested(Platform::Object^ sender, Windows::UI::Core::BackRequestedEventArgs^ e);
+
Platform::String^ SemanticInterpretation(Platform::String^ tag, Windows::Media::SpeechRecognition::SpeechRecognitionResult^ result);
};
}
diff --git a/Samples/CortanaVoiceCommand/cpp/AdventureWorks/View/TripDetails.xaml b/Samples/CortanaVoiceCommand/cpp/AdventureWorks/View/TripDetails.xaml
index b1919c2ff3..3c1b2c5d69 100644
--- a/Samples/CortanaVoiceCommand/cpp/AdventureWorks/View/TripDetails.xaml
+++ b/Samples/CortanaVoiceCommand/cpp/AdventureWorks/View/TripDetails.xaml
@@ -28,21 +28,9 @@
-
-
-
-
-
-
-
-
-
+
+
diff --git a/Samples/CortanaVoiceCommand/cpp/AdventureWorks/View/TripListView.xaml b/Samples/CortanaVoiceCommand/cpp/AdventureWorks/View/TripListView.xaml
index dd5e9429d4..41cbe5cf86 100644
--- a/Samples/CortanaVoiceCommand/cpp/AdventureWorks/View/TripListView.xaml
+++ b/Samples/CortanaVoiceCommand/cpp/AdventureWorks/View/TripListView.xaml
@@ -24,15 +24,10 @@
-
-
-
-
-
-
-
-
+
+
+
DefaultViewModel->SelectionChanged();
+
+ // Immediately deselect the item so that the list box returns to its initial state.
+ DefaultViewModel->SelectedTrip = nullptr;
+
}
void TripListView::Footer_Click(Platform::Object^ sender, RoutedEventArgs^ args)
@@ -53,9 +57,11 @@ TripListViewModel^ TripListView::DefaultViewModel::get()
void TripListView::OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs^ args)
{
defaultViewModel = (TripListViewModel^)this->DataContext;
- if (this->DefaultViewModel->Trips->Size == 0)
+ if (!tripsLoaded)
{
+ // On initial launch, load the trips.
defaultViewModel->LoadTrips();
+ tripsLoaded = true;
}
if (args->Parameter != nullptr)
diff --git a/Samples/CortanaVoiceCommand/cpp/AdventureWorks/View/TripListView.xaml.h b/Samples/CortanaVoiceCommand/cpp/AdventureWorks/View/TripListView.xaml.h
index 1955791148..0f40439ea8 100644
--- a/Samples/CortanaVoiceCommand/cpp/AdventureWorks/View/TripListView.xaml.h
+++ b/Samples/CortanaVoiceCommand/cpp/AdventureWorks/View/TripListView.xaml.h
@@ -38,5 +38,6 @@ namespace AdventureWorks
private:
TripListViewModel^ defaultViewModel;
+ bool tripsLoaded = false;
};
}
diff --git a/Samples/CortanaVoiceCommand/cpp/AdventureWorks/ViewModel/TripViewModel.cpp b/Samples/CortanaVoiceCommand/cpp/AdventureWorks/ViewModel/TripViewModel.cpp
index 6b59f92b50..25fab19e53 100644
--- a/Samples/CortanaVoiceCommand/cpp/AdventureWorks/ViewModel/TripViewModel.cpp
+++ b/Samples/CortanaVoiceCommand/cpp/AdventureWorks/ViewModel/TripViewModel.cpp
@@ -37,12 +37,6 @@ TripViewModel::TripViewModel(TripStore^ store)
[this](Object^ parameter) {return true; },
[this](Object^ parameter) {this->DeleteTrip(); });
- goBackCommand = ref new RelayCommand(
- [this](Object^ parameter) {return true; },
- [this](Object^ parameter) {
- auto rootFrame = dynamic_cast (Window::Current->Content);
- rootFrame->Navigate(TripListView::typeid);
- });
}
AdventureWorks_Shared::Trip^ TripViewModel::Trip::get()
@@ -99,11 +93,6 @@ ICommand^ TripViewModel::DeleteTripCommand::get()
return this->deleteTripCommand;
}
-ICommand^ TripViewModel::GoBackCommand::get()
-{
- return this->goBackCommand;
-}
-
///
/// Load trip data (if required), and then search the store for the specified trip.
/// Does not disambiguate, just displays the first match, for simplicity in this sample.
diff --git a/Samples/CortanaVoiceCommand/cpp/AdventureWorks/ViewModel/TripViewModel.h b/Samples/CortanaVoiceCommand/cpp/AdventureWorks/ViewModel/TripViewModel.h
index b702de77e0..3e9309798e 100644
--- a/Samples/CortanaVoiceCommand/cpp/AdventureWorks/ViewModel/TripViewModel.h
+++ b/Samples/CortanaVoiceCommand/cpp/AdventureWorks/ViewModel/TripViewModel.h
@@ -51,11 +51,6 @@ namespace AdventureWorks
Windows::UI::Xaml::Input::ICommand^ get();
}
- property Windows::UI::Xaml::Input::ICommand^ GoBackCommand
- {
- Windows::UI::Xaml::Input::ICommand^ get();
- }
-
void LoadTripFromStore(Platform::String^ destination);
void ShowTrip(AdventureWorks_Shared::Trip^ trip);
void NewTrip();
@@ -67,7 +62,6 @@ namespace AdventureWorks
Windows::UI::Xaml::Input::ICommand^ saveTripCommand;
Windows::UI::Xaml::Input::ICommand^ deleteTripCommand;
- Windows::UI::Xaml::Input::ICommand^ goBackCommand;
bool showDestinationValidation = true;
Platform::String^ destinationValidationError;
diff --git a/Samples/CortanaVoiceCommand/cs/AdventureWorks/Common/NavigationHelper.cs b/Samples/CortanaVoiceCommand/cs/AdventureWorks/Common/NavigationHelper.cs
index edd18b4d61..bc9600414f 100644
--- a/Samples/CortanaVoiceCommand/cs/AdventureWorks/Common/NavigationHelper.cs
+++ b/Samples/CortanaVoiceCommand/cs/AdventureWorks/Common/NavigationHelper.cs
@@ -1,15 +1,4 @@
-//*********************************************************
-//
-// 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;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -24,17 +13,17 @@
namespace AdventureWorks.Common
{
///
- /// NavigationHelper aids in navigation between pages. It provides commands used to
+ /// NavigationManager aids in navigation between pages. It provides commands used to
/// navigate back and forward as well as registers for standard mouse and keyboard
- /// shortcuts used to go back and forward in Windows and the hardware back button in
- /// Windows Phone. In addition it integrates SuspensionManger to handle process lifetime
- /// management and state management when navigating between pages.
+ /// shortcuts used to go back and forward. In addition it integrates SuspensionManger
+ /// to handle process lifetime management and state management when navigating between
+ /// pages.
///
///
- /// To make use of NavigationHelper, follow these two steps or
+ /// To make use of NavigationManager, follow these two steps or
/// start with a BasicPage or any other Page item template other than BlankPage.
///
- /// 1) Create an instance of the NavigationHelper somewhere such as in the
+ /// 1) Create an instance of the NaivgationHelper somewhere such as in the
/// constructor for the page and register a callback for the LoadState and
/// SaveState events.
///
@@ -52,7 +41,7 @@ namespace AdventureWorks.Common
/// { }
///
///
- /// 2) Register the page to call into the NavigationHelper whenever the page participates
+ /// 2) Register the page to call into the NavigationManager whenever the page participates
/// in navigation by overriding the
/// and events.
///
@@ -85,39 +74,47 @@ public NavigationHelper(Page page)
// When this page is part of the visual tree make two changes:
// 1) Map application view state to visual state for the page
- // 2) Handle hardware navigation requests
+ // 2) Handle keyboard and mouse navigation requests
this.Page.Loaded += (sender, e) =>
{
-#if WINDOWS_PHONE_APP
- Windows.Phone.UI.Input.HardwareButtons.BackPressed += HardwareButtons_BackPressed;
-#else
// Keyboard and mouse navigation only apply when occupying the entire window
if (this.Page.ActualHeight == Window.Current.Bounds.Height &&
this.Page.ActualWidth == Window.Current.Bounds.Width)
{
+ SystemNavigationManager systemNavigationManager = SystemNavigationManager.GetForCurrentView();
+ systemNavigationManager.AppViewBackButtonVisibility =
+ this.Frame.CanGoBack ? AppViewBackButtonVisibility.Visible : AppViewBackButtonVisibility.Collapsed;
+ systemNavigationManager.BackRequested += SystemNavigationManager_BackRequested;
+
// Listen to the window directly so focus isn't required
Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated +=
CoreDispatcher_AcceleratorKeyActivated;
Window.Current.CoreWindow.PointerPressed +=
this.CoreWindow_PointerPressed;
}
-#endif
};
// Undo the same changes when the page is no longer visible
this.Page.Unloaded += (sender, e) =>
{
-#if WINDOWS_PHONE_APP
- Windows.Phone.UI.Input.HardwareButtons.BackPressed -= HardwareButtons_BackPressed;
-#else
+ SystemNavigationManager.GetForCurrentView().BackRequested -= SystemNavigationManager_BackRequested;
+
Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated -=
CoreDispatcher_AcceleratorKeyActivated;
Window.Current.CoreWindow.PointerPressed -=
this.CoreWindow_PointerPressed;
-#endif
};
}
+ private void SystemNavigationManager_BackRequested(object sender, BackRequestedEventArgs e)
+ {
+ if (!e.Handled && this.CanGoBack())
+ {
+ e.Handled = true;
+ this.GoBack();
+ }
+ }
+
#region Navigation support
RelayCommand _goBackCommand;
@@ -211,21 +208,6 @@ public virtual void GoForward()
if (this.Frame != null && this.Frame.CanGoForward) this.Frame.GoForward();
}
-#if WINDOWS_PHONE_APP
- ///
- /// Invoked when the hardware back button is pressed. For Windows Phone only.
- ///
- /// Instance that triggered the event.
- /// Event data describing the conditions that led to the event.
- private void HardwareButtons_BackPressed(object sender, Windows.Phone.UI.Input.BackPressedEventArgs e)
- {
- if (this.GoBackCommand.CanExecute(null))
- {
- e.Handled = true;
- this.GoBackCommand.Execute(null);
- }
- }
-#else
///
/// Invoked on every keystroke, including system keys such as Alt key combinations, when
/// this page is active and occupies the entire window. Used to detect keyboard navigation
@@ -297,7 +279,6 @@ private void CoreWindow_PointerPressed(CoreWindow sender,
if (forwardPressed) this.GoForwardCommand.Execute(null);
}
}
-#endif
#endregion
diff --git a/Samples/CortanaVoiceCommand/cs/AdventureWorks/View/TripDetails.xaml b/Samples/CortanaVoiceCommand/cs/AdventureWorks/View/TripDetails.xaml
index 213620724a..4bb415ffdf 100644
--- a/Samples/CortanaVoiceCommand/cs/AdventureWorks/View/TripDetails.xaml
+++ b/Samples/CortanaVoiceCommand/cs/AdventureWorks/View/TripDetails.xaml
@@ -48,22 +48,10 @@
-
-
-
-
-
-
-
-
+
-
-
+
diff --git a/Samples/CortanaVoiceCommand/cs/AdventureWorks/View/TripListView.xaml b/Samples/CortanaVoiceCommand/cs/AdventureWorks/View/TripListView.xaml
index b5e0b43894..e4da31fd29 100644
--- a/Samples/CortanaVoiceCommand/cs/AdventureWorks/View/TripListView.xaml
+++ b/Samples/CortanaVoiceCommand/cs/AdventureWorks/View/TripListView.xaml
@@ -44,21 +44,10 @@
-
-
-
-
-
-
-
-
+
-
+