我正在使用滚动视图显示我的主页,它包含许多控件,包括2个CollectionViews,我的问题是,当用户向下滚动主页时,一旦到达CollectionView,他将卡在CollectionView的滚动器中,我希望没有滚动条的CollectionView中显示的所有项目(大约40个项目),以便用户可以继续滚动主页,并朝下面的控件浏览CollectionView的项目。 我试图为CollectionView设置一个固定的高度,但这没有用。 另外,我发现了一篇有关使用BindableLayout的文章,但我在某处读到它可能比CollectionView慢得多,并且它不支持项目布局(即使用span =“ 2”在每行上显示相邻的2个项目)
答案 0 :(得分:1)
您可以使用 FlexLayout 的BindableLayout。检查以下代码
<ScrollView Orientation="Vertical" BackgroundColor="LightBlue">
//.. other elements
<FlexLayout BindableLayout.ItemsSource="{Binding XXX}" Direction="Row"
AlignItems="Start" Wrap="Wrap" JustifyContent="SpaceAround" AlignContent="SpaceAround" >
<BindableLayout.ItemTemplate>
<DataTemplate>
//replace it with your data template
<StackLayout HeightRequest="100" WidthRequest="180" BackgroundColor="Red" Margin="10" >
<Label Text="{Binding .}" TextColor="Black" BackgroundColor="Green" />
</StackLayout>
</DataTemplate>
</BindableLayout.ItemTemplate>
</FlexLayout>
</ScrollView>
这样,您需要将每个项目的宽度设置为小于屏幕宽度的一半。否则,该商品将翘曲到下一行。