0

I've been pulling my hair out trying to get any kind of performance out of Collection View...bottom line I think using the data template and databinding is just too slow for what im trying to do. (the list has about 100 row items, never mind an infinite scrolling pattern).

Is there a way to build out the Collection View Items and add them to the Collection View manually in C# without databinding?

Sounds like a horribly tedious idea, but I've already attempted to pair down the Views and remove nested containers, and even remove the number of items being databound for each item. I've removed any converters, and really anything that could possible add to the overhead. Additionally, I've hard coded text labels in for every element that would normally be databound. It simply just can't handle anything that is more than a couple of simple visual elements. Once the count of visual elements increases to accommodate the design im trying to implement it tanks.

In the output window, when I navigate to the screen in question, it spends seconds (30-40) mostly just GCing. Rendering the UI just brings Maui to its knees. If I navigate away and come back (after i give it time to catch up), it usually just crashes the app.

Additionally, I've specified the data type on the data template, gave an explicit height on each item, and told the collection view to size based on the first item. Nothing works. Its just unusable in its current form.

  • Not really. I'd focus on solving the underlying issue. I've used CV in many apps without problems. You might try ListView as an alternative. – Jason Aug 31 '22 at 21:35
  • Sometimes it takes another developer telling me to look in the mirror for the problem. I was too close to the problem to see it. I'll post the answer, and what I found. – user19771002 Sep 01 '22 at 14:47

1 Answers1

2

Well, I feel foolish. The problem was that my CollectionView was nested inside a ScrollView which affected the sizing calculations for the CollectionView. That in turn caused CollectionView to render all children at the same time instead of paging them out.

I feel dumb. :)

  • Wow. Thanks for this. I was having performance problems with a CollectionView as well and your post helped. It turned out that I did the same thing. I didn't realize the CollectionView is already scrollable and didn't need to be wrapped in ScrollView. – Niya Aug 16 '23 at 20:08