Reply to comment


Internally, Update Controls is using object recycling. Every PersonViewModel from the prior run is put into a recycle bin before the People property is called. Then it looks for each PersonViewModel that you return in the recycle bin. If it's already there, then it reuses that one.

What I neglected to say in the article is that you should implement Equals and GetHashCode on PersonViewModel. That will make it possible for the recycle bin to find the matching object. Two PersonViewModel objects are equal if they reference the same Person.

So, yes, you are creating a new batch of PersonViewModel objects every time the Person property is updated. But the ones that are already bound to the UI are reused. That means that the ListBox items themselves are not destroyed and recreated, which would be the real performance hit. Not to mention, that would reset the scrollbar position.

I've used Update Controls for lists about that size without a noticeable performance problem. But if you go much larger I'd recommend doing something different. Beyond a couple of thousand you start to run into memory pressure from all of the internal dependency tracking. Memory might be your chief concern on the compact framework.

Let me know if you decide to take on the port.


By submitting this form, you accept the Mollom privacy policy.