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

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:
Start App (page 1)
Go to page 2
Go to page 3
Click back button (nothing happens)
Click back button (it goes to page 2)
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

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));
}

Related

Sencha Touch - Windows Phone 8 Phonegap Application Bar not hiding on back button click

We are developing an hybrid mobile application using Sencha touch 2 for Windows Phone 8.
While developing we noticed that for a number field in windows phone 8 there is no keyboard done button available.Please refer to the below screenshot.
We then decided to write a custom application bar in Windows Phone 8 - Phonegap application inside the MainPage.cs with an Done button inside that application bar.Please refer to the below screenshot.
Now the done functionality works fine but when we click on the back button of the device the keyboard hides but the application bar remains in the view as in the below screenshot
We tried overriding the back button functionality in phonegap, but when the keyboard is shown the back button click is fired only the second click ,the first click hides the keyboard and the second click fires the overridden function.
Can someone provide some alternatives or a solution on how to hide the custom application bar along with the keyboard when the back button is clicked the first time ?
In MainPage.xaml.cs add listener mentioned below which listens the event when back button is pressed in device when keypad is opened.
And pass a string from java script when ur calling particular plugin to show the application bar contains done button, by using that you can identify in which case you have to show and other case you can hide the bar.
cordova.exec(null, null, "Cordova.Extension.Commands.DoneButtonPlugin", "keyboardDoneShow", "Num");
cordova.exec(null, null, "Cordova.Extension.Commands.DoneButtonPlugin", "keyboardDoneHide", "input string");
private void CordovaView_LayoutUpdated(object sender, EventArgs e)
{
if (CordovaView.Content.DesiredSize.Height == 0)
{
if(App.appBar.IsVisible)
App.HideShell();
}
else
{
if (App.NumKey == "\"Num\"") {
if(!App.appBar.IsVisible)
App.ShowShell();
}
}
}

What is the hype around the Windows Phone 8 back button?

I know how to implement the back button. My question is about the desired behaviour (as I experienced there is a hype around it that the good implementation of back button is required to sell the app in the store).
There is the official source:
http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff402536(v=vs.105).aspx#BKMK_BackButton
But I have never used a WP8 for more than 5 minutes. I understood that the "Windows" button/key is the same as android home and ios home buttons. Is it true, that the WP8 back should be the same as the android back? (Briefly navigate back through pages (screens/activities), dismiss alerts or cancel confirm popups, or if it is the first/only/final page/activity, the app should exit.)
As I experienced, there is a long-press on the back button, which brings up the app switcher (~ios double home). Is it true that I should not take care about of this button? Is the default behavoiur the same for the remaining buttons (windows, power off, camera (half and full), search)? Should I override them? Can I override them (I think I can use camera, but can I use volume controls for other purposes)?
The certification requirements lay out what the back button should do pretty well. In short, it sounds like how you described the Android back button - here are the relevant requirements:
(5.2.4.1) Pressing the Back button must return the app to the previous page or return to any previous page within the back stack.
(5.2.4.2) Pressing the Back button from the first screen of an app must close the app.
(5.2.4.3) If the current page displays a context menu or a dialog, the pressing of the Back button must close the menu or dialog and return the user to the screen where the context menu or dialog box was opened.
You don't have to handle triggering the long-press, nor do you need to handle navigation specifically (assuming you're using the NavigationService for page navigation.)
You can definitely override the camera button, but search, power, and volume are off limits.

Back button only return in Windows Phone application

Is it allowed by Windows Phone application certification rules, to only have users be able to return to a previous screen with the use of a hardware back button?
In my scenario, a user clicks on a setting button and lands at a settings page. He changes settings if he decides to, and all the changes get saved automatically, like in iOS.
But currently, the only way for the user to get out of the settings screen, is to press a hardware Back button on the phone.
Will such implementation of navigation functionality pass the Windows Phone certification?
Yes - leave the back button as the navigation method to get back to your main page after visiting the settings page. Not only is this allowed, but it is the desired method of back navigation, and it is what Windows Phone users expect. Here is a great article on the subject: http://blogs.msdn.com/b/ptorr/archive/2011/10/06/back-means-back-not-forwards-not-sideways-but-back.aspx
As far as I understand the terms of the navigation guideline is your usage the right way to go.
Back button
Pressing the back button from the first screen of an application must exit the application.
Pressing the back button must return the application to the previous page.
If the current page displays a context menu or a dialog, the pressing the Back button must close the menu or dialog and cancel the
backward navigation to the previous page.
You should only implement back button behaviors that navigate back or dismiss context menus or modal dialog boxes. All other
implementations are prohibited.
See this cheat sheet for more informations on the design guidelines.

How to disable back button of windows phone after one click

I have a problem in my app is that when the user hit back button multiple times the app become crashed.Is there any way to handle this problem ?Is any way to disable back button after the first click from a page.so further click can be avoided.The exception i am getting while hitting back button multiple time is 0x8000ffff.Is there any solution for this in windows phone 7.1?
You should fix the issue which is causing your app to crash. If you disable the back button behaviour you risk failing marketplace certification due to requirement 5.2.4[.1] http://msdn.microsoft.com/en-us/library/hh184840(v=VS.92).aspx
You can control that, here is a sample code:
private void YourPage_BackKeyPress(object sender, System.ComponentModel.CancelEventArgs e)
{
//App.NaviService.BackKeyPress(sender, e);
if (NavigationService.CanGoBack)
{
NavigationService.GoBack();
}
}

Pressing the device's back button do we have to close the Message box and cancel the backwards navigation too in WP7?

In the Certification guidelines 5.2.4 C they mentioned that if the current page displays a context menu or a dialog, the pressing of the Back button must close the menu or dialog and cancel the backward navigation to the previous page.
Is this applicable for MessageBox also?
I am using MessageBox to prompt the user to allow the location service api to use location i.e. lat and long which is in application launching.
Do I have to follow the 5.2.4 C for the MessageBox too be closed and stop back navigation.
Please guide me for standard way to implement so not to fail in Windows phone 7 Certification process.
4.Check the Back button Twice:
protected override void OnBackKeyPress( System.ComponentModel.CancelEventArgs e )
{
if (DemoPopup.isOpen)
{
e.Cancel = true;
//hide the popup
DemoPopup.IsOpen = false;
}
else
{
base.OnBackKeyPress(e);
}
}
Yes, if you have a Message Box displayed (or a Context Menu) then pressing the back button should dismiss the Message Box instead of navigating backwards, i.e. backwards navigation should not occur.
However, in the case of MessageBox.Show and ContextMenu (from the Silverlight Toolkit), I think this happens for you automatically.

Resources