简体   繁体   中英

Place a timer in a Xamarin Carousel page

I would like to place a timer in a Xamarin Forms carousel page, to make the 'swipe' happen automatically if the user does nothing.

Being new to Xamarin I'm not entirely sure if I can do this as I would outwith Xamarin, by creating a System.Timer in code-behind.

The auto swipe should happen after 3 seconds, and swipe through the carousel at 3 second intervals.

Can anyone tell me if this is a viable approach?

Solved it by using:

Device.StartTimer(TimeSpan.FromSeconds(3), () =>
{   
    // run swipe code
    Task.WaitAll(_scvm.MoveNext());
    return true;
});

After the InitialzeComponent() line

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM