Search code examples
xamarinxamarin.formsxamarin.androidxamarin.iosxamarin-studio

How to show each record of list one by one in page when swipe up/down in xamarin forms


I have a list of many records and i want to show each record on one single page. What i want is, When we do swipe up from bottom of the page, next record in list should show with animation. similarly, when we do swipe down from top of the page, previous record in list should show with animation.

I don't know how to achieve this. hope for better solution


Solution

  • Caraousel View with orientation and snap points should give you desired results

    <CarouselView BindingContext="{x:Reference BottomTabGridPageXaml}" ItemsSource="{Binding StudentList}"
                  VerticalOptions="FillAndExpand">
       <CarouselView.ItemsLayout>
                    <LinearItemsLayout Orientation="Vertical" SnapPointsType="MandatorySingle"/>
       </CarouselView.ItemsLayout>
       <CarouselView.ItemTemplate>
          <DataTemplate>
              <StackLayout VerticalOptions="FillAndExpand">
                 <Label Text="{Binding Id}" HorizontalOptions="Center" VerticalOptions="CenterAndExpand"/>
                 <Label Text="{Binding Name}" HorizontalOptions="Center" VerticalOptions="CenterAndExpand"/>
                 <Label Text="{Binding Number}" HorizontalOptions="Center" VerticalOptions="CenterAndExpand"/>
                 <Label Text="{Binding Age}" HorizontalOptions="Center" VerticalOptions="CenterAndExpand"/>
              </StackLayout>
          </DataTemplate>
       </CarouselView.ItemTemplate>
    </CarouselView>