我有一个使用Visual Studio 2013的Xamarin.Forms(1.4.2.6359)项目,并在下面创建了轮播页面 . 我想添加页面指示符,即在轮播页面顶部的点 . 这是否可以使用Xamarin Forms CarouselPage完成?
public class SplashPage : CarouselPage
{
public SplashPage ()
{
this.Children.Add(new CarouselChild("Logo.png", "Welcome"));
this.Children.Add(new CarouselChild("Settings.png", "Settings"));
}
}
class CarouselChild : ContentPage
{
public CarouselChild(string image, string text)
{
StackLayout layout = new StackLayout
{
HorizontalOptions = LayoutOptions.CenterAndExpand,
VerticalOptions = LayoutOptions.CenterAndExpand,
};
layout.Children.Add(new Image
{
Source = image,
});
layout.Children.Add(new Label
{
HorizontalOptions = LayoutOptions.CenterAndExpand,
VerticalOptions = LayoutOptions.EndAndExpand,
Text = text,
Scale = 2,
});
this.Content = layout;
}
}
2 回答
通过更改下面的CarouselChild方法,我可以通过对页面指示器进行硬编码来解决问题:
为了简单起见,我做的是:
MyCarouselPage :
Pages的 Base 类
CarouselPageIndicator
对于 n-Pages