What's the deal with "Xamarin.Forms.Label.Font is obsolete"?

SteveMacdonaldSteveMacdonald CAUniversity, Certified XTC Partners ✭✭

I'm using 1.3.

My question is simple: how do I get this warning to go away?

var nameLabel = new Label { Font = Font.SystemFontOfSize (NamedSize.Large), HorizontalOptions = LayoutOptions.CenterAndExpand, YAlign = TextAlignment.Center };

I can't find any consistent, clear documentation or explanation anywhere. Also I tried setting the label Style to title style, but it had no effect on Android or iOS (just rendered as default font).


  • GeoffArmstrongGeoffArmstrong CAMember ✭✭

    FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)),

    They obsoleted the Font property. So use the other properties that the Font property was a compound of.

  • ShantimohanElchuriShantimohanElchuri USMember ✭✭✭✭✭

    @GeoffArmstrong‌ But how to use FontFamily attribute? Can you give all the substitutes for the Font setting that @SteveMacdonald‌ used?

  • SteveMacdonaldSteveMacdonald CAUniversity, Certified XTC Partners ✭✭

    @GeoffArmstrong‌ thanks - that's what I was looking for.

  • NagashreeNagashree USMember

    Even I had faced the same warning. So i changed the code to
    label.FontSize = Font.SystemFontOfSize(16, FontAttributes.Bold).FontSize
    But, FontAttributes.Bold doesn't work.
    Its not making the label bold.
    Can anybody help me in this??

  • NagashreeNagashree USMember

    I was able to solve this.
    In Xamarin forms 1.3
    Formsize and FormAttributes are 2 different properties for a label.

  • But Label.FontSize = 0 is not working.

  • EgalitariasEgalitarias USMember ✭✭
    edited March 2015

    I wanted a label with a bold font so I tried this:

    <Label Grid.Row="0" Grid.Column="0" Font="32" FontAttributes="Bold" Text="Inspections" BackgroundColor="{Binding BackgroundColor}"></Label>

    I get a runtime error:

    No Property of name FontAttributes found

Sign In or Register to comment.