【发布时间】:2020-08-21 07:16:19
【问题描述】:
我有一个登录页面,我的代码是这样的:
<ContentPage.Content>
<Grid>
<StackLayout Orientation="Vertical" Padding="20">
<Entry Placeholder="{x:Static resources:AppResources.EMB_PLACEHOLDER}" Keyboard="Numeric" Text="{Binding EMB}"></Entry>
<Button Text="{x:Static resources:AppResources.LOGIN_BTN}" TextColor="White" Padding="0,-20" BackgroundColor="#07987f" Command="{Binding LoadLoginCommand}"></Button>
<Label
Margin="0,10,0,0" >
<Label.FormattedText>
<FormattedString>
<Span Text="{x:Static resources:AppResources.MESSAGE} "></Span>
</FormattedString>
</Label.FormattedText>
</Label>
<Grid Margin="0,10,0,0" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Label Padding="20,0,0,0" Text="{x:Static resources:AppResources.LBLLANGUAGE}" VerticalOptions="Center" FontSize="Body" TextColor="Gray" Grid.Column="0"/>
<Picker x:Name="languagePicker" Grid.Column="1" ItemsSource="{Binding Languages}" Title="{x:Static resources:AppResources.LBLLANGUAGE}" ItemDisplayBinding="{Binding Name}" SelectedItem="{Binding SelectedLanguage, Mode=TwoWay}"></Picker>
</Grid>
</StackLayout>
<StackLayout HorizontalOptions="Center" VerticalOptions="Center">
<ActivityIndicator IsVisible="{Binding IsBusy}" IsRunning="{Binding IsBusy}" HorizontalOptions="Center" VerticalOptions="Center"></ActivityIndicator>
<Label Text="{x:Static resources:AppResources.TSMSG1}" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" HorizontalOptions="Center" VerticalOptions="Center" IsVisible="{Binding IsBusy}"/>
</StackLayout>
</Grid>
</ContentPage.Content>
有一个包含语言列表的选择器。每种语言都有resx 文件。我的情况是,当我单击选择器并选择某种语言时,我想以所选语言实时更改登录页面上所有文本的语言。知道怎么做吗?
【问题讨论】:
-
您可以使用
ResourceManager。检查stackoverflow.com/questions/44410407/…
标签: xamarin.forms localization