Label View

The Label view is used to display read only text. The Label can be created both in XAML and in code.

Defining a Label with XAML

<Label Text="Hello World" />

Defining a Label in Code

var label = new Label()
{
    Text = "Hello World"
};

Changing Font Attributes

You can use the FontSize property. The number will be tranlated into Points on iOS and DPI on Android.

<Label Text="Hello World" FontSize="32" FontAttributes="Bold" />

We can set the same attributes in code :

var label = new Label()
{
    Text = "Hello World",
    FontSize = 32,
    FontAttributes = FontAttributes.Bold
};

The recommended way to change the FontSize property is to use the platform's pre-defined size.

var label = new Label()
{
    Text = "Hello World",
    FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)),
    FontAttributes = FontAttributes.Bold
};

In XAML

<Label Text="Hello World" FontSize="Large" FontAttributes="Bold" />

results matching ""

    No results matching ""