Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the Back Button Text on Xamarin.Forms

I have been trying to change the text of the back button in Xamarin.Forms without luck.

I tried already this code with no luck:

NavigationPage.SetBackButtonTitle(this, "");

I'm using a MasterDetailPage.

I tried to add the code into the constructor of the XAML cs file.

Libraries used: PRISM 6.2.0, Xamarin Forms 2.3.1.114

Any suggestion or idea?

Thanks in advance

like image 950
acido Avatar asked Aug 18 '16 20:08

acido


1 Answers

You can set the attribute NavigationPage.BackButtonTitle on ContentPage

For example:

<?xml version="1.0" encoding="utf-8"?> <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:d="http://xamarin.com/schemas/2014/forms/design" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:T3R" mc:Ignorable="d" Title="Title of Page" NavigationPage.BackButtonTitle="Cancel" x:Class="T3R.MainPage">

Remember the following:

  • I understand this only works on iOS
  • For any given page, the back button title is set by the page that presents it. This way, the button label can vary with respect to the page that precedes it on the navigation stack (of which there can be many).
like image 199
user3675131 Avatar answered Oct 02 '22 10:10

user3675131