c# - Xamarin Forms Span 保留空白

标签 c# xaml xamarin.forms

如何在 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/

相关文章:

c# - 无法从 Visual Studio : System. AccessViolationException 运行控制台应用程序

c# - 是否可以在 C# XML 文档中引用 const 字段的值?

c# - Windows Phone 8 - 使用 Binding 将 byte[] 数组加载到 XAML 图像中

ios - 使用 Mac 代理在 Visual Studio 上调试 Xamarin.Forms iOS 应用

android - 如何更改 TextInputLayout 中的提示文本大小

c# - 文本框 SpellCheck.IsEnabled - 如何计数

c# - 在 MongoDB 中添加对另一个文档的引用 | mongocsharpdriver

c# - XAML-创建类的实例

c# - 动画网格以移动或滑动到右侧 WPF

tabs - Xamarin.Android 的底部选项卡(在 Xamarin.forms 应用程序中)