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