1
我在Xamarin.Forms这一段简单的代码:StackLayout:儿童财产不能分配给
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Xamarin.Forms;
namespace ReflectedColors
{
public class ColorBlocksPage : ContentPage
{
public ColorBlocksPage()
{
Content = new StackLayout
{
};
}
}
}
我点击c
的StackLayout
成员初始化内部,以设置Children
收集和获取:
,你可以Children
是不存在的。
如果我尝试写
Content = new StackLayout
{
Children = new Label { Text = "Test"}
};
试图建立我的解决方案时,我得到了以下错误:
错误CS0200属性或索引“Layout.Children”不能 分配 - - 它是只读的
我一定在做一些愚蠢的事,但不幸的是没有线索可能是什么来源问题。
检查例如在https://developer.xamarin.com/api/type/Xamarin.Forms.StackLayout/ – Fruchtzwerg