在一个帧中添加两个stacklayot - 后面的代码(不是xaml)

时间:2018-06-04 08:28:27

标签: c# xamarin xamarin.forms

我有一个水平的stacklayout,但我需要添加一个应该在框架中其他项目之上的按钮。

我尝试添加另一个stacklayout,但它抱怨。

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};

它说我不能拥有2个stacklayouts的操作数。

1 个答案:

答案 0 :(得分:0)

View = stackLayout&& buttonStackLayout是错误的。

您需要使用:

View = new StackLayout
            {
                Orientation = StackOrientation.Horizontal,
                Children = {stackLayout , buttonStackLayout}
            };