Xamarin 如何在C#中向StackLayout模板添加两个标签?
我已经检查了StackLayout,但它似乎对我没有帮助。以下是我所拥有的:Xamarin 如何在C#中向StackLayout模板添加两个标签?,xamarin,xamarin.forms,Xamarin,Xamarin.forms,我已经检查了StackLayout,但它似乎对我没有帮助。以下是我所拥有的: public class PracticeButtons : StackLayout { public PracticeButtons() { Children = { new Label() { Text = "ABC" }; } } } 我原以为根据文件,这会起作用,但似乎根本不起作用 有人能给我一些建议吗?Children是一个IList您需要像任何
public class PracticeButtons : StackLayout
{
public PracticeButtons()
{
Children = { new Label() { Text = "ABC" }; }
}
}
我原以为根据文件,这会起作用,但似乎根本不起作用
有人能给我一些建议吗?Children是一个
IList
您需要像任何其他IEnumerable对象一样向列表中添加标签或任何其他视图
public class PracticeButtons : StackLayout
{
public PracticeButtons()
{
Children.Add(new Label() { Text = "Label 1" });
Children.Add(new Label() { Text = "Label 2" });
}
}