コード例 #1
0
        public static void AutoPlayBindingPropertyChanged(BindableObject bindable, object oldValue, object newValue)
        {
            if ((bool)newValue == true)
            {
                CarouselView cv = bindable as CarouselView;
                _cv = cv;
                //var period = (double?)cv.GetValue(PeriodProperty);
                //if (period == null)
                //{
                //    period = 2000;
                //}
                double period = 3000;
                Device.StartTimer(System.TimeSpan.FromMilliseconds(period), () =>
                {
                    IList list  = _cv.ItemsSource as IList;
                    _itemsCount = list.Count;
                    if (_itemsCount == 0)
                    {
                        return(false);
                    }
                    _cv.Position = (_cv.Position + 1) % _itemsCount;

                    var re = (bool)_cv.GetValue(AutoPlayProperty);
                    return(re);
                });
            }
        }