Xamarin 形成 CarouselView 一次只滑动一个元素

时间:2021-01-19 11:04:51

标签: xamarin.forms carousel swipe

在我的 Xamarin.Forms 项目中,我需要一次仅对一个元素进行水平轮播。是否可以通过 CarouselView 实现?建议?

这是我当前的 CarouselView 定义:

<CarouselView AbsoluteLayout.LayoutFlags="All" AbsoluteLayout.LayoutBounds="0,0,1,1"
    ItemsSource="{Binding Homes}" ItemTemplate="{StaticResource HomeTemplate}"
    PeekAreaInsets="0" IsSwipeEnabled="True" Loop="False" IsScrollAnimated="False" ItemsUpdatingScrollMode="KeepItemsInView" HorizontalScrollBarVisibility="Never" VerticalScrollBarVisibility="Never">
    <CarouselView.ItemsLayout>
        <LinearItemsLayout Orientation="Horizontal" ItemSpacing="0"  />
    </CarouselView.ItemsLayout>
</CarouselView>

1 个答案:

答案 0 :(得分:1)

您可以将 SnapPointsType 设置为 MandatorySingle 。这表示与 Mandatory 相同的行为,但一次仅滚动一项。

<CarouselView.ItemsLayout>
     <LinearItemsLayout Orientation="Horizontal" ItemSpacing="0" SnapPointsType="MandatorySingle"  />
</CarouselView.ItemsLayout>
相关问题