Changing that Back button label on iOS with Xamarin Forms
Tags: xamarin, ios, localization, xamarinforms
Published: 2019-10-13 19:16:02

---
title: Changing that Back button label on iOS with Xamarin Forms
published: true
date: 2019-05-30 11:00:41 UTC
tags: Xamarin,ios,localization,Xamarin.Forms
canonical_url: https://blog.torib.io/2019/05/30/changing-that-back-button-label-on-ios-with-xamarin-forms/
---

### Some context

I’ve been working on the app for CodecampSDQ ([iOS](https://apple.co/2MgbFfA) | [Android](http://bit.ly/2Mqsp3A)) to be celebrated on the premises of Intec this June 1st. The code is based on [this repo](https://github.com/xamarinhq/app-conference) and we have made some adequations that I will probably talk about in greater detail later.

I found myself at an impasse for a few minutes doing the localization for the app when trying to change the Back button label on iOS and that’s what I’m going to talk about next.

### The meat and potatoes

To change the label content all you have to do is set this property **NavigationPage.BackButtonTitle**. You can set it up using XAML or C#

<script src="https://gist.github.com/eatskolnikov/ec3705531521068c76473e038214a3b8.js"></script>

Here is the thing though, you need to set the property from within the ContentPage you’re navigating from, instead of the destination page. In other words, say you have **Page1** and **Page2** and you want Page2’s back button label to say “Take me home”, you would need to set the **NavigationPage.BackButtonTitle** property on **Page1** for it to work. If you set it on **Page2** it will simply not work and you will get the Back button.

### Some explaining ensues

To some of you getting started, this implementation may seem a little backward at first. You will probably think “Why would I change the presentation of a page from another page?” and that’s what happened through my mind after spending an unhealthy amount of time trying to figure out why the back labels wouldn’t change.

A good Justification may be the following: Let’s imagine you want to be able to navigate to a page from different paths (we will call these potential paths **source pages** ) and you are reusing a page to show samely structured data in different contexts (we will call that a **detail page** ). In this scenario, you want to be able to remind the user where they are going to land after pressing that back button from the detail page. With the current implementation, you can add as many source pages as you need and you don’t have to modify the Details page at all for every one of them nor will you need to pass a parameter or something in the ViewModel just to specify this value.

## In conclusion

Overall I think this is a fun simple feature that can make your life easier and help us achieve world peace but remember to implement it correctly.

If you liked the article and would like to read more articles like this I encourage you to check the other content on the site and if you really really like it I hope you share it with your pal’s and gal’s print it and paste it at your town square or just share it on social media, that works too. Thanks for passing by and have a good one.

The post [Changing that Back button label on iOS with Xamarin Forms](https://blog.torib.io/2019/05/30/changing-that-back-button-label-on-ios-with-xamarin-forms/) appeared first on [Enmanuel Toribio](https://blog.torib.io).