我正在尝试学习Xamarin App开发的基础知识,当我在手机上运行此代码时,它并没有向我显示任何标签
public partial class MainPage : ContentPage
{
public MainPage()
{
Color[] colors = { Color.White, Color.Silver, Color.Gray, Color.Blue, Color.Red, Color.DarkBlue, Color.Black, Color.Yellow, Color.Green, Color.OrangeRed, Color.Orange };
string[] colorNames = { "White", "Silver", "Gray", "Blue", "Red", "DarkBlue", "Black", "Yellow", "Green", "OrangeRed", "Orange" };
StackLayout stackLayout = new StackLayout();
int i;
for (i = 0; i < colors.Length; i++)
{
Label label = new Label
{
Text = colorNames[i],
TextColor = colors[i],
FontSize=Device.GetNamedSize(NamedSize.Large,typeof(Label))
};
stackLayout.Children.Add(label);
}
this.Content = stackLayout;
}
}
有人能解释我为什么吗?