แชร์ผ่าน


Xamarin.Forms CarouselView

Introduction

The CarouselView is a view for presenting data in a scrollable layout, where users can swipe to move through a collection of items.

Data

A CarouselView is populated with data by setting its ItemsSource property to any collection that implements IEnumerable. The appearance of each item can be defined by setting the ItemTemplate property to a DataTemplate.

Layout

By default, a CarouselView will display its items in a horizontal list. However, it also has access to the same layouts as CollectionView, including a vertical orientation.

Interaction

The currently displayed item in a CarouselView can be accessed through the CurrentItem and Position properties.

Empty views

In CarouselView, an empty view can be specified that provides feedback to the user when no data is available for display. The empty view can be a string, a view, or multiple views.

Scrolling

When a user swipes to initiate a scroll, the end position of the scroll can be controlled so that items are fully displayed. In addition, CarouselView defines two ScrollTo methods, that programmatically scroll items into view. One of the overloads scrolls the item at the specified index into view, while the other scrolls the specified item into view.