My Xamarin.Forms app displays the name of multiple items in a Listview
. The name of the article is displayed by a Binding to the name field in the table that contains these articles (Panier
).
I would like the user to be able to change the text size of the article name (when the screen resolution is low, the name is truncated).
To do this, I have provided a Parameters table which contains the size of the text chosen by the user.
But how do you indicate this in the xaml code?
Here's some of the xaml code:
<Label Text="{Binding Name}"
Margin="10,-4,0,0" FontSize="Medium" TextColor="Black"
FontAttributes="None"
VerticalOptions="Start"
Grid.Column="0"/>
So I would like to replace
FontSize="Medium"
With an instruction that would look like this:
FontSize="{Binding ???}"
The binding would fetch the value from the Parameters table.
But to find the name, I have in the code behind the instruction
BindingContext = new Panier();
Panier()
contains the Name
field, but obviously does not contain the text size.
You might need to change the BindingContext
to go to the Parameters table, but in XAML code, FontSize
is in the same place as Text.
To sum up: the user should be able to adjust the size of the text of the name of the articles displayed in the Listview
himself.
Edit for to all those who answered me :
Excuse me, I am not an experienced developer, and I did not understand what you are offering me;
I believe I will add a NameFontSize field in the Panier table. I can therefore in my xaml code have the following code:
FontSize="{Binding NameFontSize}";
The disadvantage of this solution is this additional field which means that each record will have a data concerning the size of the text, which will be the same for all the records of the table. It doesn't make much sense to repeat the same information for all records.
If I am wrong and the solution you are proposing makes more sense, please explain it to me in more detail.
Thank you very much.