相关疑难解决方法(0)

有没有办法可以在标签内部使用Spans并且还有合理的理由?

我正在使用此代码为标签内的文本添加一些颜色:

<Label.FormattedText>
  <FormattedString>
     <Span Text="I would like the word " />
     <Span Text="HERE" ForegroundColor="Red" FontAttributes="Bold" />
     <Span Text="to be in a bold font" />
   </FormattedString>
</Label.FormattedText>
Run Code Online (Sandbox Code Playgroud)

以前我一直在使用这个渲染代码来证明标签的合理性:

public class JustifiedLabelRenderer : LabelRenderer
{
    public JustifiedLabelRenderer() {}

    protected override void OnElementChanged(ElementChangedEventArgs<Label> e)
    {
        base.OnElementChanged(e);

        //if we have a new forms element, we want to update text with font style (as specified in forms-pcl) on native control
        if (e.NewElement != null)
            UpdateTextOnControl();
    }

    protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
    {
        base.OnElementPropertyChanged(sender, …
Run Code Online (Sandbox Code Playgroud)

xamarin xamarin.forms

5
推荐指数
1
解决办法
730
查看次数

标签 统计

xamarin ×1

xamarin.forms ×1