I am using xamarin carousel view. Salon is my parent list and SalonService is called as features in each Salon list item.
My code displays only one item per view. I want to display three (3) items on each carousel view.
Below is my code for lists:
Ftrs.Add(new SalonService() { Services = "Test 1", Prices = "$150" });
Ftrs.Add(new SalonService() { Services = "Test 2", Prices = "$150" });
Ftrs.Add(new SalonService() { Services = "Test 3", Prices = "$150" });
Ftrs.Add(new SalonService() { Services = "Test 4", Prices = "$150" });
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 });
Below is my code for carousel view:
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);
Current Output:
- Test Title 1
- Test 1
Expected Output:
- Test Title 1
- Test 1
- Test 2
- Test 3
My carousel view is only displaying one item per view. I want to display three items per view.