【问题标题】:Xamarin Forms: Line break unicode works on xaml but on in code behindXamarin Forms:换行符 unicode 在 xaml 上工作,但在代码后面
【发布时间】:2020-08-16 04:27:12
【问题描述】:

我想在 xamarin 标签中换行。但它仅适用于 xaml,但不适用于后面的代码。文本不是静态的,所以我不能在 XAML 中拥有它。谁能建议如何通过后面的代码换行?

作品:

<StackLayout x:Name="DetailsContainer" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Padding="20" InputTransparent="True" WidthRequest="0">
    <Label x:Name=lbl Text="Line one &#10; Line two." StyleClass="h3"/>
</StackLayout>

如果在 xaml 中像这样更新文本,标签将在文本中出现换行符,但如果我在后面的代码中执行相同操作则不起作用

【问题讨论】:

  • "Line one \n Line two." 不起作用吗?
  • 没有,但是第一行 \r\n 第二行正在运行。

标签: c# xaml xamarin xamarin.forms


【解决方案1】:

在 C# 中,您应该使用 \r\n(windows) \n(Unix 类型) 或更好的 Environment.NewLine

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-03-07
    • 1970-01-01
    • 2021-12-03
    • 1970-01-01
    • 1970-01-01
    • 2019-03-30
    • 2021-03-08
    • 2017-12-31
    相关资源
    最近更新 更多