无法在 Xamarin Forms 的堆栈布局中同时显示两个滚动视图

Cannot display two scrollview together in stacklayout in Xamarin Forms

我尝试在一个堆栈布局中添加两个水平滚动视图。但只显示最后一个滚动视图(scrollView1)。为什么第一个scrollView不显示?

var avatarLayout = new StackLayout()
            {
               HeightRequest = 500,
            };

StackLayout st = new StackLayout()
                {
                    Orientation = StackOrientation.Horizontal
                };
                st.Children.Add(postImage1);
                st.Children.Add(postImage2);
                st.Children.Add(postImage3);

StackLayout st1 = new StackLayout()
                {
                    Orientation = StackOrientation.Horizontal
                };
                st1.Children.Add(postImage4);
                st1.Children.Add(postImage5);
                st1.Children.Add(postImage6);

                ScrollView scrollView = new ScrollView()
                    {
                    HorizontalOptions = LayoutOptions.Fill,
                    Orientation = ScrollOrientation.Horizontal,
                    Content = new StackLayout{
                        Orientation = StackOrientation.Horizontal,
                        Children = {st}
                    }
                };

                ScrollView scrollView1 = new ScrollView()
                {
                    HorizontalOptions = LayoutOptions.Fill,
                    Orientation = ScrollOrientation.Horizontal,
                    Content = new StackLayout
                    {
                        Orientation = StackOrientation.Horizontal,
                        Children = {st1}
                    }
                };
                avatarLayout.Children.Add(avatarImage);
                avatarLayout.Children.Add(friends);
                avatarLayout.Children.Add(scrollView);
                avatarLayout.Children.Add(cars);
                avatarLayout.Children.Add(scrollView1);
                avatarLayout.Children.Add(posts1);

已解决。

上面的代码没有向 st1 添加任何子项,因此 scrollView1 没有任何内容可显示。看起来代码应该显示 scrollView(而不是 scrollView1),但包含用于两个 ScrollView 容器的内容。我怀疑创建 st1 后的调用应该是 st1.Children.Add(...) 而不是 st.Children.Add(...).