【发布时间】:2019-08-07 12:06:20
【问题描述】:
我们正在 Visual Studio 2019 中使用 Xamarin 开发购物车应用程序,我的问题是,我想从图像列表中从左到右自动播放幻灯片,请给我解决此问题的解决方案
这是我的代码:
using System;
using System.Collections.Generic;
using Xamarin.Forms;
namespace Shopping.Pages
{
public partial class GalleryPage : ContentPage
{
public GalleryPage()
{
InitializeComponent();
List<string> students = new List<string>()
{
"Manikandan.png",
"RajKumar.png",
"Suresh.png",
"Karthick.png",
"Prakash.png",
"Kavin.png",
"Aathif.png",
"Prabhu.png",
"Aravind.png",
};
listViewCarousal.ItemsSource = students;
}
void OnTapGestureRecognizerTapped1(object sender, EventArgs args)
{
}
}
}
GalleryPage.xaml:
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Shopping.Pages.GalleryPage">
<ContentPage.Content>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="8*" />
<RowDefinition Height="2*" />
</Grid.RowDefinitions>
<controls:CarouselViewControl Grid.Row="0"
Orientation="Horizontal"
InterPageSpacing="10"
VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand"
x:Name="listViewCarousal"
ShowIndicators="True">
<controls:CarouselViewControl.ItemTemplate>
<DataTemplate>
<Image Source="{Binding .}"/>
</DataTemplate>
</controls:CarouselViewControl.ItemTemplate>
</controls:CarouselViewControl>
<Image Source="Autoplay.png" Grid.Row="1">
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="OnTapGestureRecognizerTapped" />
</Image.GestureRecognizers>
</Image>
</Grid>
</ContentPage.Content>
</ContentPage>
注意:当我单击自动播放图像时,我想将图像列表显示为幻灯片。
【问题讨论】:
-
这是来自github.com/alexrainman/CarouselView 的
CarouselView吗?您似乎缺少 XAML 中的命名空间导入 ...