标签 Xamarin 表单中的粗体字体

Ric*_*ati 2 fonts xamarin.forms

这是我的 ContentPage 标签:

<Label FontSize="Small"
       Grid.Row="0"
       Grid.Column="0"
       VerticalOptions="Center" 
       Text="{Binding ItemCode,StringFormat='Code: {0}'}">
</Label>
Run Code Online (Sandbox Code Playgroud)

我想将粗体字体应用于文本“代码:”的这一部分,有没有办法在axml页面上做到这一点?

Die*_*uza 5

您可以使用该FormattedText属性来设置文本的部分。像这样:

<Label Grid.Row="0"
       Grid.Column="0"
       FontSize="Small"
       VerticalOptions="Center" >
    <Label.FormattedText>
        <FormattedString>
            <FormattedString.Spans>
                <Span Text="Code: "
                      FontAttributes="Bold"/>
                <Span Text="{Binding ItemCode}" />
            </FormattedString.Spans>
        </FormattedString>
    </Label.FormattedText>
</Label>
Run Code Online (Sandbox Code Playgroud)