Hi all!
I have a problem with animations that I hope you can help me with.
I want to create a "rotating image" component that I can use where I want, especially in lists, without having to manually clean up every time I use it. I have found this piece of code on this forum, and it works fine:
while (!cancellation.IsCancellationRequested && element.IsVisible && running)
{
await element.RotateTo(360, 1200, Easing.Linear);
await element.RotateTo(0, 0); // reset to initial position
}
The problem is with the stop condition. IsVisible isn't false when navigating away from the page, so my next idea was to find the page that holds the component and listen to Appearing and Disappearing. This seems to work (although not very pretty), but if I use the component in a ViewCell, I can't use element.Parent.Parent... to get the page. Is there another approach to this? We have a similar problem somewhere else where we use MessagingCenter to clean up, but I really don't want to bother the users of the component with manual cleanup code and risk memory leaks.
Thanks in advance!
Mark