I am developing an app in Xamarin forms that supports English and Arabic languages. I implemented the translation logic and it works fine, but I faced a case where I have to translate the tabs titles in a tabbed page but did not know-how. So the question is how can I access the title of the tabs on a tabbed page from the .cs file? Thanks in advance.
Your TabbedPage consists of several NavigationPages. You need to set the Title of the NavigationPage. Here is an example with xaml:
TabbedPage:
<?xml version="1.0" encoding="utf-8"?>
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:yourApp;assembly=yourApp"
x:Class="yourApp.MainPage">
<NavigationPage Title="Bottom Title (Page 1)">
<x:Arguments>
<local:Page1/>
</x:Arguments>
</NavigationPage>
<NavigationPage Title="Bottom Title (Page 2)">
<x:Arguments>
<local:Page2/>
</x:Arguments>
</NavigationPage>
</TabbedPage>
And one NavigationPage:
<?xml version="1.0" encoding="utf-8"?>
<ContentPage
Title="Top Title (Page 1)"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="yourApp.Page1">
</ContentPage>
For more information take a look at the documentation
Edit: Here an example for C#:
TabbedPage:
public class MainPage : TabbedPage
{
public MainPage ()
{
var page1 = new NavigationPage (new Page1());
page1.Title = "Bottom Title (Page1)";
var page2 = new NavigationPage (new Page2());
page2.Title = "Bottom Title (Page2)";
Children.Add (page1);
Children.Add (page2);
}
}
one NavigationPage:
public class Page1 : ContentPage
{
public Page1()
{
Title = "Top Title (Page1)";
}
}