Xamawin • zam-ah win | noun
A quick, easy to implement enhancement for a Xamarin App that improves performance, appearance, or functionality
Have you ever wanted to change the back button text in the navbar for iOS in Xamarin.Forms? I certainly have; by default the text is set to be the title of the previous page. Now, maybe I’m not good at Googling things, but I finally stumbled across the solution! As usual, my salvation came from a James Monetmagno Post. Thanks to the magic of Attached Properties we can access properties from the NavigationPage that hosts out ContentPage. Specifically, we want to modify a property called “BackButtonTitle”. Setting via our xaml is a cinch:
<?xml version="1.0" encoding="UTF-8"?> <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="PrismForms.Views.HomePage" Title="{Binding Title}" NavigationPage.BackButtonTitle="Return"> <ContentPage.Content>
We can also do it in the code behind:
NavigationPage.SetBackButtonTitle(this, "Return");
Either way, the end result is a back button that says exactly what we want it to! Keep in mind that this must be done on the page you are navigating from for this to work properly on the page you navigate to.
One thought on “XamaWIN – Controlling the Back Button Text”