Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
3914
Expand/Collapse All
posted

Hi,

How can I Expand/Collapse All.

I use the following code. But it throws the exception

"Collection was modified; enumeration operation may not execute".

What am I doing wrong?

 

private void ExpandAll(Collection<PivotHeaderCell> pivotHeaderCells)
        {
            foreach (PivotHeaderCell cell in pivotHeaderCells)
            {
                cell.IsExpanded = true;
                if (cell.Children.Count > 0)
                    CollapseAll(cell.Children);

            }
          
          
        }

 

Thanks

Sangeetha

 

  • 3914
    posted

    Sorry, here is the right code:

    private void ExpandAll(Collection<PivotHeaderCell> pivotHeaderCells)
            {
                foreach (PivotHeaderCell cell in pivotHeaderCells)
                {
                    cell.IsExpanded = true;
                    if (cell.Children.Count > 0)
                        ExpandAll(cell.Children);

                }
              
              
            }