C# 在帧代码隐藏中添加两个StackLayout(不是xaml)
我有一个水平的stacklayout,但我需要添加一个按钮,该按钮应该位于框架中其他项目的上方 我尝试添加另一个stacklayout,但它抱怨C# 在帧代码隐藏中添加两个StackLayout(不是xaml),c#,xamarin,xamarin.forms,C#,Xamarin,Xamarin.forms,我有一个水平的stacklayout,但我需要添加一个按钮,该按钮应该位于框架中其他项目的上方 我尝试添加另一个stacklayout,但它抱怨 var stackLayout = new StackLayout { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.Cent
var stackLayout = new StackLayout
{
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.Center,
Orientation = StackOrientation.Horizontal,
Children = {image, label}
};
var buttonStackLayout = new StackLayout
{
Children = {addButton}
};
return new ViewCell { View = stackLayout};
当我尝试这样做时:
return new ViewCell { View = stackLayout && buttonStackLayout};
它说我不能有两个stackLayout的操作数。View=stackLayout&&buttonStackLayout是错误的 您需要使用:
View = new StackLayout
{
Orientation = StackOrientation.Horizontal,
Children = {stackLayout , buttonStackLayout}
};