Hi, I am creating a dynamic carousel with students. This part works just fine, but I would like to be able to click on each sudent and then navigate to a new page with their information on it, and that I am really struggling with -/
Here is how i generate the carousel from an ObservableCollection:
ObservableCollection collection = new ObservableCollection();
collection.Add(new StudentData { name = "Soren Hanson", schoolclass = "4. grade", course = "Math" }); collection.Add(new StudentData { name = "Michael Trane", schoolclass = "7. grade", course = "English" }); collection.Add(new StudentData { name = "Tammy Jump", schoolclass = "1. grade", course = "English" });
Now, I am using a datatemplate to generate each student to the carousel like this:
DataTemplate template = new DataTemplate(() =>
{
var imageBtn = new Button();
imageBtn.Image = "Images/default.png";
imageBtn.Clicked += delegate { // ADDING THE CURRENT STUDENT TO MY CURRSTUDENT OBJECT // //App.currStudent = collection....... var menteeOptions = new MenteeOptions(); imageBtn.Navigation.PushAsync(menteeOptions); } } carousel.ItemTemplate = template; carousel.PositionSelected += pageChanged; carousel.ItemsSource = collection;
As you can see, I am trying, when I click the button, to get the specific student into an temporary StudentData object, but am not succesfull :-(
I really hope someone can help me here cause I am kind of stuck!
Thanks in advance.
Answers
Hi) Try this plugin https://github.com/AndreiMisiukevich/CardView
It works fine
carousel.SelectedItem what you need