【问题标题】:Xamarin.Forms Image Slider in XamlXaml 中的 Xamarin.Forms 图像滑块
【发布时间】:2016-08-03 18:14:07
【问题描述】:

我想做图像滑块。但我无法在 xaml 端显示更多图像。这是我的代码;

Xaml:

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

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

当我尝试这个时,它会显示最后一张图片,但我想像旋转木马一样显示它们。

[1]: [http://i.stack.imgur.com/C74tr.png ----我想要这样的

[2]: http://i.stack.imgur.com/ElnFn.png ---- 这是我的页面

【问题讨论】:

  • 不清楚你有什么。您的图像是否在网格或堆栈布局中。你能添加你所有的 contentpage xaml 代码吗?

标签: xamarin xamarin.forms


【解决方案1】:

从您的图片来看,您似乎可以使用 Xamarin 中的“新”Xamarin.Forms'CarouselView

Nuget:CarouselView

参考: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>

【讨论】:

    【解决方案2】:

    你可以试试 Xlabs 的ImageGallery

    【讨论】:

      猜你喜欢
      • 2017-08-15
      • 2016-11-22
      • 2018-02-23
      • 2015-04-12
      • 2015-10-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多