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
560
Grouping and expand all rows
posted

Hi!

We have a xamWebGrid in our application with grouping enabled. For this grid we have a button for expanding all rows. I copied the code for expanding all rows from the samples browser: 

    public void ExpandRows(RowCollection rows)
    {
      foreach (Row row in rows)
      {
        row.IsExpanded = true;

        if (row.HasChildren)
        {
          ExpandRows(row.ChildBands[0].Rows);
        }
      }
    }

When I click Expand I get an exception in the ExpandRows method on this line: ExpandRows(row.ChildBands[0].Rows);

The exception:

-           row.ChildBands    'row.ChildBands' threw an exception of type 'System.InvalidCastException'      Infragistics.Silverlight.Controls.Primitives.ChildBandCollection {System.InvalidCastException} 

-           base  {System.InvalidCastException: Unable to cast object of type 'Infragistics.Silverlight.Controls.RowCollection' to type 'Infragistics.Silverlight.Controls.Primitives.ChildBandCollection'.

   at Infragistics.Silverlight.Controls.Row.get_ChildBands()

   at Infragistics.Silverlight.Controls.Primitives.GroupByRow.get_ChildBands()}      System.SystemException {System.InvalidCastException}

Do you have any idea how this can be solved?

Thanks,

Arjen