lundi 13 juin 2022

Xamarin.Forms Random List

I am running into a problem when trying to pull random List items, it keeps getting an "Out of Range Exception" rather than starting back at the begining. How do I get it to keep pulling randomly from the list?

        var rand = new Random();
        var next = rand.Next(1);

        Device.StartTimer(TimeSpan.FromSeconds(1), () =>
        {
            _countSeconds--;

            if (_countSeconds == 0)
            {
                count--; //trying to use count instead of index to go past the 4 list items
                next++;
                _countSeconds = 3;

                if (count < 6 && count >= 0)
                {
                    BindingContext = Footwork2[next];                       
                }
                else
                {
                    return false;
                }
            };

            CountLabel.Text = _countSeconds.ToString();

            return true;
        });



Aucun commentaire:

Enregistrer un commentaire