I need to show the UWP ShellBackButton as a button in my user control in Template10.
The ShellBackButton is the back button on top left in the application but I need to show this as a button in the main screen so the user can click on it.
I have researched this, but could not find how to do this.
There a property in App.xaml.cs
to show the button on top left, that is ShowShellBackButton
and I want to have this as a button in my user control view.
As from the comments, i thought it's completely irrelevant to keep the old answer. So The updated answer is below:
The Control
This is just a basic dummy version of the control and you will need to add visual states and other resources, assets and custom styles but the skeleton would look like below:
The C#
Once created the Control, now you need to add the default style to it: The Resource Dictionary
The above are the two necessary things required for the control to function properly.
Later on you can edit the resource dictionary to personalize the control and once you have it all figured out you can freeze it and when you use it in other apps, you can simply override the default style instead of manually changing the resource dictionary each time.
I hope this helps. I've uploaded a copy of a template 10 version of the solution on GitGub
Finally, I got this working. Here is the solution for future reference, if you ever stuck in this situation.
The following will need to be inside your ViewModel inheriting the ViewModelBase in Template10.
You can also make it so that the back button is visible or not by using the CanGoBack property.
Template10 provides a navigation service through the Bootstrapper (and surfaces it through the ViewModelBase.NavigationService property) that you can use to handle backwards navigation in your button:
if ( NavigationService.CanGoBack ) NavigationService.GoBack();
See https://github.com/Windows-XAML/Template10/wiki/Bootstrapper#navigation-service for more details about INavigationService and the Bootstrapper.