Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.