2016-08-03 28 views
1

Ich möchte Image Slider machen. Aber ich konnte nicht mehr Bilder auf der XAML-Seite zeigen. Hier ist mein Code;Xamarin.Forms Image Slider in Xaml

XAML:

 <Image //first image 
       Aspect="AspectFill" 
       Source="{Binding Hotel.HotelImages[0].FullPath}" /> 

    <Image //second image 
       Aspect="AspectFill" 
       Source="{Binding Hotel.HotelImages[1].FullPath}" /> 

, wenn ich das versuche, es mir zeigen letzte Bild, aber ich möchte sie beide wie Karussell zeigen.

[1]: [http://i.stack.imgur.com/C74tr.png ---- Ich möchte ähnliche

[2]: http://i.stack.imgur.com/ElnFn.png ---- seine meine Seite

+0

Es ist nicht klar, was Sie haben Dort. Sind Ihre Bilder in einem Raster oder Stapellayout? kannst du bitte all deinen contentpage xaml code hinzufügen? – batmaci

Antwort

0

Von Ihrem Bild, scheinen, wie Sie die "neue" verwenden könnte Xamarin.Forms 'CarouselView von Xamarin:

Nuget: CarouselView

Ref: https://blog.xamarin.com/flip-through-items-with-xamarin-forms-carouselview/

<cv:CarouselView ItemsSource="{Binding Zoos}" x:Name="CarouselZoos"> 
    <cv:CarouselView.ItemTemplate> 
     <DataTemplate> 
     <Grid> 
      <Grid.RowDefinitions> 
      <RowDefinition Height="*"/> 
      <RowDefinition Height="Auto"/> 
      </Grid.RowDefinitions> 
      <Image Grid.RowSpan="2" Aspect="AspectFill" Source="{Binding ImageUrl}"/> 
      <StackLayout Grid.Row="1" BackgroundColor="#80000000" Padding="12"> 
      <Label TextColor="White" Text="{Binding Name}" FontSize="16" HorizontalOptions="Center" VerticalOptions="CenterAndExpand"/> 
      </StackLayout> 
     </Grid> 
     </DataTemplate> 
    </cv:CarouselView.ItemTemplate> 
    </cv:CarouselView>