如何在 Xamarin Forms 中的格式化文本标签中保留空格我试过了,但它似乎不起作用
<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>
我收到这个错误
错误位置 22:35。找不到“空格”的属性、可绑定(bind)属性或事件,或者值和属性之间的类型不匹配。
最佳答案
使用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>
关于c# - Xamarin Forms Span 保留空白,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52935275/