【发布时间】:2015-01-04 03:08:45
【问题描述】:
根据 Xamarin.Forms documentation,我应该能够使用 Font.SystemFontOfSize([size], [FontAttributes]) 方法设置字体属性。但是当我创建一个新的空白应用程序(Xamarin.Forms Portable)项目并将以下代码添加到可移植项目中的 App.cs 时,由于某种原因,我无法访问 Font.SystemFontOfSize(...) 的所有重载,也无法访问到Xamarin.Forms.FontAttributes枚举。
// FontExample/App.cs
using System;
using Xamarin.Forms;
namespace FontExample {
public class App {
public static Page GetMainPage() {
return new ContentPage {
Content = new Label {
Text = "Hello, Forms !",
Font = Font.SystemFontOfSize(14, FontAttributes.Italic)
},
};
}
}
}
似乎只有两个 SystemFontOfSize 重载,编译器给了我:
当前上下文中不存在名称“FontAttributes”[...]
该项目似乎有所有默认引用(.NET、Xamarin.Forms.Core、Xamarin.Forms.Xaml),我没有碰它们。
但是,如果我使用完全相同的设置下载a sample project(从具有相同引用的便携式项目中调用Font.SystemFontOfSize),该项目编译得很好,我似乎可以访问所有Font.SystemFontOfSize 重载以及Xamarin.Forms.FontAttributes 枚举。
为什么我自己创建新项目时无法访问所有 Xamarin.Forms API 功能?我找不到新创建的空白应用程序 (Xamarin.Forms Portable) 和上面链接的示例项目之间的任何显着差异。
【问题讨论】:
标签: c# xamarin xamarin.forms