Run the attached sample, when you comment out the function call "AddConditionalFormatting()" there is no stack overflow exception.
Attaching stackoverflow trace
Hello Rohit,
Thank you for your post. I have been looking into it. I have created a sample project from the code snippets you have sent. I have change the check for the rows in the GridRowsCollectionChanged method to Grid.Rows != null. This way the sample works without a StackOverflow Exception, when you are adding the ConditionalFormation to the xamGrid.
Please find the attached sample application and feel free to let me know if you have any further questions on this matter.
Hi Gregna,
So your solution is to not call "Enumerable.Any"? Please tell me you are joking.
Checking for "not equal to null" (what you suggested as a "SOLUTION") and invoking "Enumerable.Any()" are two totally different unrelated concepts/functions. To read more about "Enumerable.Any" please look at the MSDN article http://msdn.microsoft.com/en-us/library/bb534972.aspx
I am using Grid.Any() so I could ensure there is atleast one row in the grid collection so I could apply conditional formatting.
Secondly did you try to understand why we are getting stack overflow exception and thought of taking it with the developers? Since your solution is not a solution and I could reproduce the issue with the old and latest service release, please kindly consider taking it with developers for a fix.
Thanks so much,
Rohit
I have logged this behavior with our developers in our tracking system, with an issue ID of 151865. I have also created a support ticket on your behalf with number CAS-122955-P9P6C7 in order to link the development issue to it so that you are automatically updated when a Service Release containing your fix is available for download.
Currently to avoid the issue you can use the following code snipped in the RowsCollectionChanged event:
Grid.Rows.CollectionChanged -= GridRowsCollectionChanged;
if (Grid.Rows.Any())
{
i++;
}
Grid.Rows.CollectionChanged += GridRowsCollectionChanged;