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
4040
Problem with accessing rows in XamGrid
posted

Hello,

Here is my problem, I would like to show the elements present visually in the XamGrid and the total of the elements.

I have two questions : 

 1 - Is there a way to have the number of elements in a group directly ?

 2 - I tried a solution but I got a problem : 

      for that I need to iterate through the rows of the XamGrid but when I try to make a foreach on the Rows property a stackoverflowexception is thrown.

I attached a sample.

Regards.

XamgridNbElements.zip
  • 27093
    posted

    Hello,

     

    I have been looking into this for you, and it appears to be a timing issue that is caused by iterating with foreach while the Rows collections is being changed. I can suggest putting your RowsCollectionChanged event code into a Dispatcher invoked function to delay its execution like so:

     

    void Rows_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)

    {

        Dispatcher.BeginInvoke(new Action(() =>

        {

            if (this.xg.GroupBySettings.GroupByColumns.Count > 0)

                this.AfficherNombreElements();

            else

                this.Elements.Text = this.xg.Rows.Count.ToString();

     

        }));            

    }

     

    Please let me know, if I can be of any further assistance on the matter.