我在学Xamarin,我知道C#的基础知识。一个我遇到的第一个代码是这是如何工作的?究竟发生了什么?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Xamarin.Forms;
namespace Hello
{
public class App : Application
{
public App()
{
// The root page of your application
MainPage = new ContentPage
{
Content = new StackLayout
{
VerticalOptions = LayoutOptions.Center,
Children = {
new Label {
HorizontalTextAlignment = TextAlignment.Center,
Text = "Welcome to Xamarin Forms!"
}
}
}
};
}
protected override void OnStart()
{
// Handle when your app starts
}
protected override void OnSleep()
{
// Handle when your app sleeps
}
protected override void OnResume()
{
// Handle when your app resumes
}
}
}
在那里我有一个问题,就是
Children = {
new Label {
HorizontalTextAlignment = TextAlignment.Center,
Text = "Welcome to Xamarin Forms!"
}
我不明白发生了什么这里的一部分。什么是Children
?它分配给了什么?
儿童StackLayout –
的属性会更加准确,这是从['布局'](https://developer.xamarin.com/继承财产API /属性/ Xamarin.Forms.Layout%3CT%3E.Children /) –
UnholySheep
此链接给你不错的主意https://developer.xamarin.com/api/type/Xamarin.Forms.StackLayout/ – Valkyrie