Xamarin forms CarouselView 一次只滑动一个元素
Xamarin forms CarouselView swipe only one element at a time
在我的 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>
您可以将 SnapPointsType 设置为 MandatorySingle
。这表示与强制相同的行为,但一次只滚动一项。
<CarouselView.ItemsLayout>
<LinearItemsLayout Orientation="Horizontal" ItemSpacing="0" SnapPointsType="MandatorySingle" />
</CarouselView.ItemsLayout>
在我的 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>
您可以将 SnapPointsType 设置为 MandatorySingle
。这表示与强制相同的行为,但一次只滚动一项。
<CarouselView.ItemsLayout>
<LinearItemsLayout Orientation="Horizontal" ItemSpacing="0" SnapPointsType="MandatorySingle" />
</CarouselView.ItemsLayout>