V
V
Vladimir Korotenko2020-04-03 18:05:15
Xamarin
Vladimir Korotenko, 2020-04-03 18:05:15

How to change language dynamically in Xamarin Shell?

The entire application is localized using resources. However, shell elements are not localized when the language is changed.
In general, I solved this problem by simply sharing my research.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Korotenko, 2020-04-03
@firedragon

So what happened: The key point is Title="{Binding AppShellSettings, Mode=OneWay}"
In this case, developers used OneTime binding due to speed, after changing the binding mode, you can dynamically change the text. Accordingly, when you change the ViewModel, the switching occurs as intended.

<Shell xmlns="http://xamarin.com/schemas/2014/forms"
       xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
       xmlns:views="clr-namespace:SpecialForcesDirectory.Views;assembly=SpecialForcesDirectory"
       xmlns:code="clr-namespace:SpecialForcesDirectory.Code;assembly=SpecialForcesDirectory"
       x:Class="SpecialForcesDirectory.Page1" >
    <FlyoutItem Title="Main" FlyoutDisplayOptions="AsMultipleItems" Route="main">
        <Tab Title="{Binding AppShellMain,Mode=OneWay }" Icon="outline_home_white_48.png">
            <ShellContent Title="{Binding AppShellMain, Mode=OneWay }" Icon="outline_home_white_48.png" Route="quota" ContentTemplate="{DataTemplate views:QuotaPage}"/>
        </Tab>
        <Tab Title="{Binding AppShellNotes , Mode=OneWay}" Icon="outline_bookmarks_white_48.png">
            <ShellContent Title="{Binding AppShellNotes , Mode=OneWay}" Icon="outline_bookmarks_white_48.png" Route="notes" ContentTemplate="{DataTemplate views:NotesPage}"/>
        </Tab>
    </FlyoutItem>
    <ShellContent Title="{Binding AppShellInfo, Mode=OneWay}" StyleId="NONE" Route="about" Icon="outline_error_outline_white_24.png" ContentTemplate="{DataTemplate views:AboutPage}"/>
    <ShellContent Title="{Binding AppShellSettings, Mode=OneWay}" Icon="outline_settings_white_48.png" StyleId="NONE" Route="settings" ContentTemplate="{DataTemplate settings:SettingPage}"/>
</Shell>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question