Xamarin形成Label新线 [英] Xamarin forms Label new line
本文介绍了Xamarin形成Label新线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的Xamarin表单页面中有一个Label
,它从其视图模型接收到它的Text
,并且文本包含\n
字符.
如何使Label
自动将文本分为两行?
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?
推荐答案
<Label FontSize="Medium" TextColor="Gray" Text="{translation:TranslationResource MyExpertsView_NoExpertsText}" IsVisible="{Binding IsNoExpertsFound}"></Label>
由于从资源文件中检索了文本,因此Label
的Text
属性将输入视为纯文本,并且不允许使用任何转义字符.
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.
您可以考虑对TranslationResource
中的字符串进行预处理(将所有\ n替换为换行符).
You may consider pre-processing the strings (replacing all \n to line feeds) from theTranslationResource
.
这篇关于Xamarin形成Label新线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文