Xamarin.Forms列表到对象列表的控件

问题描述:

Xamarin中的哪个控件可用于通过带有左右箭头的对象列表(例如屏幕快照中的一个)列出对象?

Which control in Xamarin can be utilized to do listing through a list of objects with the arrows left and right such as the one on the screenshot?

Xmarin.forms中没有这样的控件.但是您可以自己实现.

There is no such a control in Xmarin.forms .But you can implement it by yourself.

在xaml中

in xaml

<Grid VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
  <Grid.RowDefinitions>

  </Grid.RowDefinitions>

 <Grid.ColumnDefinitions>
     <ColumnDefinition Width="0.15*" />
     <ColumnDefinition Width="0.7*" />
     <ColumnDefinition Width="0.15*" />           
 </Grid.ColumnDefinitions>

 <StackLayout Grid.Column="0" VerticalOptions="CenterAndExpand" HorizontalOptions="CenterAndExpand">
     <Image Source="xxx" x:Name="rightBtn"/>   
 </StackLayout>

 <controls:CarouselViewControl Grid.Column="1" Orientation="Horizontal" InterPageSpacing="10" Position="{Binding myPosition}" ItemsSource="{Binding myItemsSource}" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
     <controls:CarouselViewControl.ItemTemplate>
        <DataTemplate>
         <local:MyView />
         <!-- where MyView is a ContentView -->
        </DataTemplate>
     </controls:CarouselViewControl.ItemTemplate>
  </controls:CarouselViewControl>

  <StackLayout Grid.Column="2" VerticalOptions="CenterAndExpand" HorizontalOptions="CenterAndExpand">
     <Image Source="xxx" x:Name="leftBtn"/>
  </StackLayout>

</Grid>

您可以使用 CarouselView .并单击向右向左按钮时更改其position.您可以添加

You can use CarouselView . And change the position of it when you click right or left button .You can add a tap gesture recognizer on image or use ImageButton if you want to set button image by yourself. Or you can use default arrows of CarouselView .