I’m using a new item Basic Template with the app name and back button.
It is being used inside of a “Blank” project.
However, the back button is not responding to touch events.
This following is code that was generated. The back button just disappears.
<Button x:Name="backButton" IsEnabled="{Binding Frame.CanGoBack, ElementName=pageRoot}" Style="{StaticResource BackButtonStyle}" Click="GoBack"/>
I even tried making my own Click Handle and tried navigating myself with.
this.Frame.Navigate(typeof(MainPage));
However that isn’t working either. Probably due to something that auto generated because I can create a button myself and wire it up for that (so I’m really trying to stick with the Templates).
Any ideas please?
Edit:
I found it really odd none of the Navigation is working. After drilling some more it appears to be something with LayoutAwarePage. I’m missing something here. Will post updates.
Edit: Sorry about that. I added the event click listeners back in (I must have removed that copying around). However that still does not fix my issue. I tried setting the back button to the “GoBack” function and when you hit the back button it just disappears. I also tried creating my own method and trying to navigate myself and still did not work.
You should not need to write any of your own code to enable the back button, as it ties into the underlying navigation framework automatically. If there is a page in the back stack to navigate to, the back button will be enabled.
What you are missing, from what I can see, is that if you start your app on the Basic page that you added, there’s nothing in the back stack of the navigation framework for you to navigate to.
I tested your scenario using the following steps:
Double-clicked the button, and added the following code to the click event handler:
this.Frame.Navigate(typeof(BasicPage1));
Ran the project, and the back button worked as expected.