水平列表视图 Xamarin.Forms
问题描述:
是否可以像图像一样在 Xamarin.Forms
中使用 horizontal scroll
创建 ListView
Is any way to create ListView
with horizontal scroll
in Xamarin.Forms
like image
这就是我为垂直所做的
var myListView = new ListView
{
ItemTemplate = new DataTemplate(typeof(ImageCell))
};
答
从 Xamarin Forms 2.3 开始,CarouselView
就可以做到这一点,还有更多.在此处阅读更多信息.
As of Xamarin Forms 2.3 CarouselView
does just that, and more. Read more here.
<ContentView HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
<CarouselView ItemsSource="{Binding MyDataSource}">
<CarouselView.ItemTemplate>
<DataTemplate>
<Label Text="{Binding LabelText}" />
</DataTemplate>
</CarouselView.ItemTemplate>
</CarouselView>
</ContentView>