Use xamarin community toolkit translation with picker item display binding

Shereif Awad 96 Reputation points
2021-07-14T22:33:19.613+00:00

Can I use translation on item displaying binding

If I have a class

public class Madhab
{
    public string Name { get; set; }
    public string Title { get; set; }
    public string ETitle { get; set; }
    public int value { get; set; }
    public LocalizedString DisplayName { get; set; }
}

and set an item in a list

new List<Madhab>
            {
                new Madhab { Name = "Shafii", DisplayName = new(() => AppResources.Shafii), Title = AppResources.Shafii, ETitle = "Shafii", value = (int)AsrJuristicMethods.Shafii }
            };

                    <Picker
                        x:Name="Madhabpicker"
                        Title="{xct:Translate Choose_Madhab}"
                        ItemDisplayBinding="{Binding DisplayName.Localized}"
                        ItemsSource="{Binding PrayesMadhab}"
                        SelectedItem="{Binding SelectedPrayesMadhab, Mode=TwoWay}"
                        VerticalOptions="Center" />

Can the binding display item change according to language change

Developer technologies | .NET | Xamarin
{count} votes

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.