Xamarin Forms listview viewcell translation

mhmdmhmd Member ✭✭

I have 2 Resources file for translation in my project. I'm using the parameters in my layouts and it working fine but I have a ListView that I need to bind a parameter to it from this resource file!

  <Label Text="Quantity" HorizontalTextAlignment="Center" TextColor="#231F20" FontFamily="{StaticResource MyriadProRegularFont}" Grid.Column="0" Grid.Row="0">
                                                    <Label.FontSize>
                                                        <OnIdiom Phone="12" Tablet="14"/>
                                                    </Label.FontSize>
                                                </Label>

This label is placed in a ListView and I need to bind it to a parameter in the resource file. How can I do that?

Thank you in advance!

Answers

  • mhmdmhmd Member ✭✭

    I solved it by setting "Access Modifier" into public in the Resource file

    And binding the label to the parameter:

         <Label Text="{x:Static controls2:LanguageResource.quantity}" HorizontalTextAlignment="Center" TextColor="#231F20" FontFamily="{StaticResource MyriadProRegularFont}" Grid.Column="0" Grid.Row="0">
                                                            <Label.FontSize>
                                                                <OnIdiom Phone="12" Tablet="14"/>
                                                            </Label.FontSize>
                                                        </Label>
    

    And this xmlns is placed in the top of the XAML file

    xmlns:controls2="clr-namespace:AppXamarin.Resources"

Sign In or Register to comment.