Skip to content

Instantly share code, notes, and snippets.

@reddvid
Last active March 16, 2019 10:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reddvid/af859ad558164c3d0631704142d12f7b to your computer and use it in GitHub Desktop.
Save reddvid/af859ad558164c3d0631704142d12f7b to your computer and use it in GitHub Desktop.
private void OnNavigated(object sender, NavigationEventArgs e)
{
// Each time a navigation event occurs, update the Back button's visibility
SystemNavigationManager.GetForCurrentView ().AppViewBackButtonVisibility =
((Frame)sender).CanGoBack ?
AppViewBackButtonVisibility.Visible :
AppViewBackButtonVisibility.Collapsed;
}
private void RootFrame_PointerPressed(object sender, PointerRoutedEventArgs e)
{
Frame rootFrame = Window.Current.Content as Frame;
if (e.Pointer.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Mouse)
{
var properties = e.GetCurrentPoint(rootFrame).Properties;
bool backPressed = properties.IsXButton1Pressed;
bool forwardPressed = properties.IsXButton2Pressed;
if (backPressed ^ forwardPressed)
{
if (backPressed && rootFrame.CanGoBack)
{
rootFrame.GoBack();
}
if (forwardPressed && rootFrame.CanGoForward)
{
rootFrame.GoForward();
}
e.Handled = true;
}
}
}
private void OnBackRequested(object sender, BackRequestedEventArgs e)
{
Frame rootFrame = Window.Current.ContentasFrame;
if (rootFrame.CanGoBack)
{
e.Handled = true;
rootFrame.GoBack();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment