I have a
If anyone has performance issues with
ListView - here's what should be done about it:
Do not execute any expensive operations on UI thread. In my case it was not exactly it, but similar. The offending code was hidden in item constructor, it tried to make some string conversions on start. Very bad idea, all expensive operations were moved to getters which solved half of the problem. The item constructor should be empty. No initial values. No initialization at all. All properties should be read via getters. This will result in executing 20 such operations per view instead of like 20000, but only if UI virtualization is used.
Use MVVM pattern, so do not add items directly, create an item source and add items to the source. This would allow built-in UI virtualization which is essential where you have a large number of items. Search "UI virtualization ListView" in Google for more details. This solved the problem definitely.
Think of data virtualization if populating the item source is too slow. In my case this was unnecessary. When getting ALL the data is relatively cheap - we're good. If not - we have to get only a chunk of data which is currently needed to be shown.
A simpler control template could increase application performance a little bit on some low end mobile devices.
If you use unmanaged code anywhere in your application, double check it, I forgot calling
DestroyIcon once, and it resulted in very weird, unexpected behavior. So dispose anything disposable, destroy unused handles and such. Make triple sure it's done, I wasted countless hours on debugging such things. To be clear: unreleased resources didn't cause any performance issues, it caused other unexpected behavior like weird exceptions, disappearing icons and such. The issues seemed to come from