Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows 10 UWP app - Back button only works when pressed the second time

I am developing a Windows 10 UWP app with Visual Studio 2015. I am working on the back button functionality right now. Unfortunately there is a problem. When I press the back button (either on a Phone or on the PC) it doesn't go back to the previous page. When I press it again it works.

It is like this example:

  1. Start App (page 1)
  2. Go to page 2
  3. Go to page 3
  4. Click back button (nothing happens)
  5. Click back button (it goes to page 2)
  6. Click back button (it goes to page 1)

So the first time when you want to go back it needs two presses... why? Additionally I've found out that the first press doesn't trigger the back button event. But why?

I am using the implementation as described in this article: http://www.wintellect.com/devcenter/jprosise/handling-the-back-button-in-windows-10-uwp-apps

like image 294
XHotSniperX Avatar asked Oct 03 '15 01:10

XHotSniperX


1 Answers

It has to do with SplitView staying open and holding the back event. You should close it if you are using it as overlay.

private void SettingsButton_Click(object sender, RoutedEventArgs e)
{
    this.SplitView.IsPaneOpen = false;
    Frame.Navigate(typeof(SettingsPage));
}
like image 126
Dživo Jelić Avatar answered Sep 28 '22 15:09

Dživo Jelić