Xamarin Forms 轮播视图 c# 的同一索引上的多个列表项

Xamarin Forms Multiple list items on same index of carousel view c#

我正在使用 xamarin 轮播视图。 Salon 是我的 parent 列表,SalonService 在每个 Salon 列表项中被称为功能。

我的代码每次视图只显示一个项目。我想在每个轮播视图上显示三 (3) 个项目。

下面是我的列表代码:

Ftrs.Add(new SalonService() { Services = "Test 1", Prices = "0" });
Ftrs.Add(new SalonService() { Services = "Test 2", Prices = "0" });
Ftrs.Add(new SalonService() { Services = "Test 3", Prices = "0" });
Ftrs.Add(new SalonService() { Services = "Test 4", Prices = "0" });

salons.Add(new Salon() { ImgUrl = "test.png", Title = "Test Title 1", Features = Ftrs });
salons.Add(new Salon() { ImgUrl = "test.png", Title = "Test Title 2", Features = Ftrs });
salons.Add(new Salon() { ImgUrl = "test.png", Title = "Test Title 3", Features = Ftrs });
salons.Add(new Salon() { ImgUrl = "test.png", Title = "Test Title 4", Features = Ftrs });
salons.Add(new Salon() { ImgUrl = "test.png", Title = "Test Title 5", Features = Ftrs });
salons.Add(new Salon() { ImgUrl = "test.png", Title = "Test Title 6", Features = Ftrs });

下面是我的轮播视图代码:

foreach (var item in data)
{
 DataTemplate salonDataTemplate = new DataTemplate(() =>
 {
    // some code
 });

Resources = new ResourceDictionary();
Resources.Add("salonTemplate", salonDataTemplate);

int countIndex = 1;
int newPageCount = 1;

foreach (var newItem in item.Features)
{
    if (newPageCount <= 3)
    {
        //same carousal view
    }
    else
    {
        countIndex++;
        //new carousal view
    }
    newPageCount++;
} }

var list_Featured = new CarouselView()
{
    BackgroundColor = Color.White,
    //ItemsSource = item.Features,
    ItemsSource = newList,
        ItemTemplate = (DataTemplate)Resources["salonTemplate"], HeightRequest = 150 
};

StackLayout stkList = new StackLayout();
stkList.IsVisible = false;
stkList.Children.Add(list_Featured);

当前输出:

预期输出:

我的轮播视图每个视图只显示一个项目。我想在每个视图中显示三个项目。

我通过创建列表列表实现了我想要的结果。

像这样:

List<List<string>> myList = new List<List<string>>();
myList.Add(new List<string> { "a", "b" });
myList.Add(new List<string> { "c", "d", "e" });