2016-08-15 12 views
0

1つのスタックレイアウトに2つの水平スクロールビューを一緒に追加しようとしています。しかし最後のスクロールビュー(scrollView1)のみが表示されます。なぜ最初にscrollViewが表示されないのですか?Xamarinフォームのstacklayoutに2つのスクロールビューを一緒に表示できません

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

解決済み。

答えて

1

上記のコードはst1に子を追加していないため、scrollView1には何も表示されません。コードではscrollView(scrollView1ではなく)が表示されるはずですが、両方のScrollViewコンテナ用のコンテンツが表示されているようです。 st1の作成後の呼び出しはst1.Children.Add(...)ではなく、st.Children.Add(...)である必要があります。

+0

ありがとう、それは愚かなミスだった –

関連する問題