【问题标题】:Xamarin forms CarouselView swipe only one element at a timeXamarin 形成 CarouselView 一次只滑动一个元素
【发布时间】:2021-01-19 11:04:51
【问题描述】:

在我的 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>

【问题讨论】:

  • 是的,感谢它在 Android 中工作。我也会在 iOS 中测试它

标签: xamarin.forms carousel swipe


【解决方案1】:

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

<CarouselView.ItemsLayout>
     <LinearItemsLayout Orientation="Horizontal" ItemSpacing="0" SnapPointsType="MandatorySingle"  />
</CarouselView.ItemsLayout>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-02
    • 1970-01-01
    • 2021-08-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多