I have a Label in my Xamarin forms page, that receives it's Text from it's view model, and the text contains the \n character.
How can I make the Label to automatically split the text into two different rows?
15
votes
It should automatically split into two lines.
- Utsav Dawn
Of course it should, but unfortunately it doesn't. Please note that the text is received from a resource file, it is not part of the XAML.
- IdoT
Does it happen on iOS/Android?
- Prashant Cholachagudda
6 Answers
2
votes
Copied from a thread in Xamarin Forum
Probably your code:
<Label FontSize="Medium" TextColor="Gray" Text="{translation:TranslationResource MyExpertsView_NoExpertsText}" IsVisible="{Binding IsNoExpertsFound}"></Label>
Since your text is retrieved from a resource file, the Text property of Label treats the input as plain text and will not allow any escape characters.
You may consider pre-processing the strings (replacing all \n to line feeds) from theTranslationResource.
39
votes
4
votes