Count PivotItems

Andrew Bryant 21 Reputation points
2019-12-05T17:24:16.887+00:00

I am writing a local app to be used as a wallboard/dashboard tool. The idea is to loop through various WebViews of SSRS reports.

A counter is operated via a DespatcherTimer and each time a set interval is hit, the SelectedIndex on the pivot is incremented (BigPivot.SelectedIndex++) but obviously this fails when it hits the end of the PivotItems list.

Other tools have a SelectedIndexCollection.Count property that can be used to set th upper limit of the loop. What would I need to do to do the same with a Pivot?

Universal Windows Platform (UWP)
0 comments No comments
{count} votes

Accepted answer
  1. Fay Wang - MSFT 5,201 Reputation points
    2019-12-06T03:26:30.55+00:00

    Hello,​

    Welcome to our Microsoft Q&A platform!

    As you said, you need to set the upper limit of the loop to avoid the SelectedIndex exceeding its maximum number. So You can try to use BigPivot.Items.Count property to set.

    private int index = 0;  
    private void dispatcherTimer_Tick(object sender, object e)  
    {  
            index++;  
            if (index < BigPivot.Items.Count)   
            {  
                    BigPivot.SelectedIndex++;  
            }  
            else {   
                    // do something  
            }  
                  
    }  
    

    Thanks.


0 additional answers

Sort by: Most helpful