【发布时间】:2017-11-26 08:04:04
【问题描述】:
我一直在尝试使用 Shared 策略构建一个非常基本的 Xamarin.Forms 应用程序,但我什至无法在我的 Android 模拟器上显示任何内容。
我尝试在 MainPage.xaml.cs 中设置我的 MainPage,然后将其传递给 App.xaml.cs 中的MainPage。我没有收到任何警告或错误,但我的模拟器只显示一个空白屏幕。有人看到我做错了吗?
我所有的其他代码都是您创建新共享项目时生成的样板代码。现在我只专注于 Android 项目。
App.xaml\App.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Xamarin.Forms;
namespace Phoneword
{
public partial class App : Application
{
public App()
{
MainPage = new MainPage();
}
...
}
}
MainPage.xaml\MainPage.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
public class MainPage : ContentPage
{
public MainPage()
{
Content = new StackLayout
{
VerticalOptions = LayoutOptions.Center,
Children = {
new Label {
HorizontalTextAlignment = TextAlignment.Center,
Text = "Test"
}
}
};
}
}
【问题讨论】:
标签: c# android xamarin xamarin.forms xamarin.android