英文:
How can we wrap words in a lable in .net maui 7
问题
这是 .Net Maui <Label> 代码
<Label x:Name="LblName" FontSize="Default" LineBreakMode="WordWrap" TextColor="White"></Label>
我试图使文本换行,但到目前为止,似乎没有任何效果。我已经尝试了所有与"LineBreakMode(s)"一起使用"MaxLines"的方法。
标签中的数据来自代码后台文件,使用"LblName"。我已经尝试了所有与"LineBreakMode(s)"一起使用"MaxLines"的方法。
英文:
Here is the .Net Maui <Label> code
<Label x:Name="LblName" FontSize="Default" LineBreakMode="WordWrap" TextColor="White" ></Label>
I'm trying to wrap the text but so far, nothing seems to be working. I've used all of the "LineBreakMode(s)" in conjunction with the "MaxLines".
The data in label is coming from the code behind file using the "LblName".
I've used all of the "LineBreakMode(s)" in conjunction with the "MaxLines".
答案1
得分: 3
我能够重现这个问题。只能显示一行。
实际上,这是GitHub上已知的问题:在具有列定义的网格中标签无法正确渲染 #10494。hartez的评论提供了令人信服的解释,因为列定义设置为自动宽度会导致无限宽度。这个问题目前仍未解决。你可以关注这个帖子。
作为一种解决方法,你可以将列定义设置为*或给定一个具体的值。
希望对你有帮助。
英文:
Well, I can reproduce this issue. Only one line can be shown.
In fact it's a known issue on Github: Label doesn't render correctly when in a Grid with column definitions #10494. And hartez comments gave compelling explanation that it is caused because the ColumnDefinitions is set to Auto which makes a infinite width. This issue is still unsolved now. You could follow this thread.
For workaround, you could set the ColumnDefinitions to * or give a specific value.
Hope it works for you.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论