并排对齐按钮

Align buttons side by side

我正在尝试将最后 2 个按钮彼此相邻对齐(并排),这在 XAML 中要容易得多,我如何使用代码方法实现此目的?

MainPage = new ContentPage
        {
            Content = new StackLayout
            {
                VerticalOptions = LayoutOptions.Center,
                Spacing = 40,
                Children = {
                    new Label {
                        XAlign = TextAlignment.Center,
                        VerticalOptions = LayoutOptions.CenterAndExpand,
                        HorizontalOptions = LayoutOptions.CenterAndExpand,
                        Text = "Hey there here is where you spent your time!"
                    },
                    new Label()
                    {
                        XAlign = TextAlignment.Center,
                        VerticalOptions = LayoutOptions.CenterAndExpand,
                        HorizontalOptions = LayoutOptions.CenterAndExpand,
                        Text = "Time spent near beacon A: "
                    },
                    new Label()
                    {
                        XAlign = TextAlignment.Center,
                        VerticalOptions = LayoutOptions.CenterAndExpand,
                        HorizontalOptions = LayoutOptions.CenterAndExpand,
                        Text = "Time spent near beacon B: "
                    },
                    new Button()
                    {
                        VerticalOptions = LayoutOptions.Start,
                        HorizontalOptions = LayoutOptions.Start,
                        Text = "Start Tracking"
                    },
                    new Button()
                    {
                        VerticalOptions = LayoutOptions.Start,
                        HorizontalOptions = LayoutOptions.Start,
                        Text = "Stop Tracking"
                    }
                }
            }
        };

感谢任何意见。

我让它与一些像这样的 StackLayout inception 一起工作:

    MainPage = new ContentPage
    {
        Content = new StackLayout
        {
            VerticalOptions = LayoutOptions.Center,
            Spacing = 40,
            Children = {
                new Label {
                    XAlign = TextAlignment.Center,
                    VerticalOptions = LayoutOptions.CenterAndExpand,
                    HorizontalOptions = LayoutOptions.CenterAndExpand,
                    Text = "Hey there here is where you spent your time!"
                },
                new Label()
                {
                    XAlign = TextAlignment.Center,
                    VerticalOptions = LayoutOptions.CenterAndExpand,
                    HorizontalOptions = LayoutOptions.CenterAndExpand,
                    Text = "Time spent near beacon A: "
                },
                new Label()
                {
                    XAlign = TextAlignment.Center,
                    VerticalOptions = LayoutOptions.CenterAndExpand,
                    HorizontalOptions = LayoutOptions.CenterAndExpand,
                    Text = "Time spent near beacon B: "
                },

                new StackLayout()
                {
                    HorizontalOptions = LayoutOptions.Center,
                    Orientation = StackOrientation.Horizontal,
                    Children = {
                        new Button()
                        {
                            VerticalOptions = LayoutOptions.Start,
                            HorizontalOptions = LayoutOptions.Start,
                            Text = "Start Tracking"
                        },
                        new Button()
                        {
                            VerticalOptions = LayoutOptions.Start,
                            HorizontalOptions = LayoutOptions.Start,
                            Text = "Stop Tracking"
                        }
                    }
                }

            }
        }
    };