Xamarin CarouselView and the List -> Detail paradigm
According to your needs I wrote a small example for your reference.
First create a CarouselView on the xaml page, add a CollectionView inside it and add a click event.
Here is the xaml code:
<StackLayout>
<CarouselView ItemsSource="{Binding Mydates}">
<CarouselView.ItemTemplate>
<DataTemplate>
<StackLayout>
<Frame HasShadow="True"
BorderColor="DarkGray"
CornerRadius="5"
Margin="20"
HeightRequest="300"
HorizontalOptions="Center"
VerticalOptions="CenterAndExpand">
<CollectionView ItemsSource="{Binding data2}">
<CollectionView.ItemTemplate>
<DataTemplate>
<StackLayout>
<StackLayout.GestureRecognizers >
<TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped"/>
</StackLayout.GestureRecognizers>
<Label Text="{Binding .}"/>
</StackLayout>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</Frame>
</StackLayout>
</DataTemplate>
</CarouselView.ItemTemplate>
</CarouselView>
</StackLayout>
The click information can be obtained in the background method, and then you can make other logical judgments.
Here is the background code:
public partial class MainPage : ContentPage
{
public ObservableCollection<Class1> Mydates { get; set; } = new ObservableCollection<Class1>();
public MainPage()
{
InitializeComponent();
Mydates.Add(new Class1() { data1 = "aaa",data2 = new List<string>() { "aaa","bbb","cccc"} });
Mydates.Add(new Class1() { data1 = "bbb", data2 = new List<string>() { "ddd", "eeee", "ffffff" } });
Mydates.Add(new Class1() { data1 = "ccc", data2 = new List<string>() { "ggg", "hhhh", "iii" } });
BindingContext = this;
}
private void TapGestureRecognizer_Tapped(object sender, EventArgs e)
{
var sta = sender as StackLayout;
var mydata = (sta.Children[0] as Label).Text;
}
}