Reputation: 2079
Hello I am trying to apply a custom font to a Label using the following code
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="ExerClub.Pages.Profile" Title="Profile">
<StackLayout>
<Label Text="Login">
<Label.FontFamily>
<OnPlatform x:TypeArguments="x:String">
<OnPlatform.iOS>MarkerFelt-Thin</OnPlatform.iOS>
<OnPlatform.Android></OnPlatform.Android>
<OnPlatform.WinPhone></OnPlatform.WinPhone>
</OnPlatform>
</Label.FontFamily>
</Label>
<Label Text="Club Name"/>
<Label Text="More randomness"/>
</StackLayout>
</ContentPage>
Code Behind
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace ExerClub.Pages
{
public partial class Profile : ContentPage
{
public Profile()
{
InitializeComponent();
}
}
}
This is taken from Xamarin.forms Documentation
I am getting the following error on iOS
System.ArgumentException: Object of type 'System.String' cannot be converted to type 'Xamarin.Forms.View'.
I am new to Xamarin and don't really understand why this might fail.
Upvotes: 0
Views: 354
Reputation: 3698
You need to put font name <x:String>fontName</x:String>
tags or simply write like below:
<Label Text="Login">
<Label.FontFamily>
<OnPlatform x:TypeArguments="x:String"
iOS="MarkerFelt-Thin" Android=""
WinPhone=""/>
</Label.FontFamily>
</Label>
Upvotes: 1