只是想知道如何将其设置为Xamarin CarouselViewControl?我设法在其他产品中找到它,但在Xamarin中找不到?
请帮助。
答案 0 :(得分:2)
您可以通过将 <table>
<tr>
<th *ngFor="let item of data.columnNames">{{item}}</th>
</tr>
<tr *ngFor="let rowData of data.rows">
<td *ngFor="let el of rowData">{{el}}</td>
</tr>
</table>
附加到CarouselViewControl
XAML:
Behaviour
AutoscrollCarouselBehavior.cs Reference
xmlns:cv="clr-namespace:CarouselView.FormsPlugin.Abstractions;assembly=CarouselView.FormsPlugin.Abstractions"
xmlns:behaviour="clr-namespace:TestApp.Behaviours;assembly=TestApp"
<cv:CarouselViewControl x:Name="carousel"
ItemsSource="{Binding MySampleItems}"
ShowIndicators="true"
Orientation="Horizontal">
<cv:CarouselViewControl.Behaviors>
<behaviour:AutoscrollCarouselBehavior />
</cv:CarouselViewControl.Behaviors>
<cv:CarouselViewControl.ItemsSource>
<!--Content of Carousel goes here-->
</cv:CarouselViewControl.ItemsSource>
</cv:CarouselViewControl>
这将自动滚动轮播页面,您可以根据需要设置public class AutoscrollCarouselBehavior : Behavior<CarouselView.FormsPlugin.Abstractions.CarouselViewControl>
{
/// <summary>
/// Scroll delay in milliseconds
/// </summary>
public int Delay { get; set; } = 3000;
private bool runTimer;
private CarouselViewControl attachedCarousel;
protected override void OnAttachedTo(CarouselViewControl bindable)
{
base.OnAttachedTo(bindable);
runTimer = true;
attachedCarousel = bindable;
Device.StartTimer(TimeSpan.FromMilliseconds(Delay), () =>
{
MoveCarousel();
return runTimer;
});
}
protected override void OnDetachingFrom(CarouselViewControl bindable)
{
runTimer = false;
base.OnDetachingFrom(bindable);
}
void MoveCarousel()
{
if (attachedCarousel.ItemsSource != null)
{
if (attachedCarousel.Position < attachedCarousel.ItemsSource.GetCount() - 1)
{
attachedCarousel.Position++;
}
else
{
attachedCarousel.Position = 0;
}
}
}
}
。
答案 1 :(得分:1)
库存Xamarin.Forms CarouselView目前不支持此功能。团队正在从头开始重新实现CarouselView,并且列表中也包含“自动滑动”。
您可以在此处找到完整的建议和进度:https://github.com/xamarin/Xamarin.Forms/issues/4996