简体   繁体   中英

How to get Gallery focus position

I'm playing with Xamarin Gallery. Wish to get the focus position from time to time.

When reach 1 seconds it will go to OnTimedEvent , here the code

 System.Timers.Timer timer = new System.Timers.Timer();
 timer.Interval = 1000;
 timer.Elapsed += OnTimedEvent;
 timer.Enabled = true;

On the OnTimedEvent i would like to get the focus position;

 private void OnTimedEvent(object sender, System.Timers.ElapsedEventArgs e)
 {
     int position = gallery.SelectedItemPosition();
 }

Hope someone can help, Thanks

I get it already. I forget that we can use ToString() to get the data.

Here the code :

int position;
int.TryParse(gallery.SelectedItemPosition.ToString(), out position);

Sorry that i'm new in Xamarin Android. Thanks for view.

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