0
你好我想用下面的代碼應用自定義字體的標籤Xamarin.forms自定義字體異常
<?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>
代碼
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();
}
}
}
這是從Xamarin.forms Documentation
採取的背後我在iOS上收到以下錯誤
System.ArgumentException: Object of type 'System.String' cannot be converted to type 'Xamarin.Forms.View'.
我是Xamarin新手,不太明白爲什麼這可能會失敗。
能否請您顯示完整的頁面?除非我忽略了某些事情,否則錯誤似乎不是來自這裏。 –
我在後面添加了代碼。我沒有真正改變任何東西,教程也沒有提及任何東西。 – xerotolerant
您是否使用NuGet的最新版Xamarin.Forms?如果沒有,更新和重建。 – therealjohn