【问题标题】:Xamarin Forms Span preserve white spaceXamarin Forms Span 保留空白
【发布时间】:2019-03-26 21:05:10
【问题描述】:

如何在 Xamarin 表单中的格式化文本标签中保留空白我试过了,但它似乎不起作用

            <Label FontSize="Medium">
                <Label.FormattedText>
                    <FormattedString>
                        <Span xml:space="preserve">On PO: </Span>
                        <Span xml:space="preserve"> </Span>
                        <Span FontAttributes="Bold"  FontSize="Large" Text="{Binding Qty}"/>
                    </FormattedString>
                </Label.FormattedText>
            </Label>

我收到此错误

Error Position 22:35. No property, bindable property, or event found for 'space', or mismatching type between value and property.

【问题讨论】:

  • 你想渲染一个空白区域吗?
  • 是的,您可以看到标签有 3 个跨度,当前跨度之间没有空格

标签: c# xaml xamarin.forms


【解决方案1】:

使用 span 的 text 属性给空间。

 <Label FontSize="Medium">
            <Label.FormattedText>
                <FormattedString>
                    <Span Text="On PO: "/>
                    <Span Text=" "/>
                    <Span FontAttributes="Bold"  FontSize="Large" Text="{Binding Qty}"/>
                </FormattedString>
            </Label.FormattedText>
 </Label>

【讨论】:

  • 我发现 标签中指定的任何前导/尾随不间断空格(“ ”)删除 - 这个解决方案效果很好。
猜你喜欢
  • 2019-01-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-10-06
  • 2018-07-18
  • 2018-01-17
  • 2010-09-20
  • 1970-01-01
相关资源
最近更新 更多