GiampaoloGabba / Xamarin.Plugin.SharedTransitions

Shared Element Transitions between pages in Xamarin.Forms (IOS/Android)
MIT License
414 stars 57 forks source link

Csharp (C#) #27

Closed willowvil closed 4 years ago

willowvil commented 4 years ago

Hello,

I´m not able to set up the transition working with a ListView. Here is my code:

Page 1:

myList.ItemSelected += (sender, e) =>
            {
                var item = (Item)SelectedItem;
                SharedTransitionNavigationPage.SetTransitionSelectedGroup(this, item.id);
                App.Current.MainPage.Navigation.PushAsync(new Page2(), true);
            };

ViewCell:

var myImage = new CachedImage();
Plugin.SharedTransitions.Transition.SetName(myImage, "image");
Plugin.SharedTransitions.Transition.SetGroup(myImage, **???????**);

Page 2:

var myImage = new CachedImage();
Plugin.SharedTransitions.Transition.SetName(myImage, "image");

Thank you!

GiampaoloGabba commented 4 years ago

During your ItemSelected event you are setting the SelectedGroup with item.id SharedTransitionNavigationPage.SetTransitionSelectedGroup(this, item.id);

So in your ViewCell you need to set group value with item.id too

The SelectedGRoup property needs to match the Group property in the selected cell, otherwise the plugin cant find what element need to be shared between the transition.

Here an example using listview with MVVM

Here an example with using Listview with ItemSelected event (inside a Shell)