Xamarin 简单的 CarouselPage
using Xamarin.Forms;
using System.Collections.Generic;
namespace one
{
public partial class App : Application
{
public App()
{
List<ContentPage> pages = new List<ContentPage>(0);
Color[] colors = { Color.Red, Color.Green, Color.Blue };
foreach (Color c in colors) {
pages.Add(new ContentPage {
Content = new StackLayout {
Children = {
new Label {
Text = c.ToString()
},
new BoxView {
Color = c,
VerticalOptions = LayoutOptions.CenterAndExpand
}
}
}
});
}
MainPage = new CarouselPage {
Children = {
pages[0],
pages[1],
pages[2]
}
};
}
protected override void OnStart()
{
// Handle when your app starts
}
protected override void OnSleep()
{
// Handle when your app sleeps
}
protected override void OnResume()
{
// Handle when your app resumes
}
}
}
效果图: