编程语言
首页 > 编程语言> > c#-Xamarin形式跨度保留空白

c#-Xamarin形式跨度保留空白

作者:互联网

我如何在Xamarin Forms的Formatted Text Label中保留空白,我尝试过此操作,但似乎不起作用

            <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.找不到“空格”的属性,可绑定属性或事件,或值和属性之间的类型不匹配.

解决方法:

使用跨度的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>

标签:xamarin-forms,xaml,c
来源: https://codeday.me/bug/20191108/2008236.html