Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I speed up ListBox rendering and ListCollectionView filtering?
    text
    copied!<p>A two-pronged question here, but I think these two subjects are entwined enough to warrant their inclusion together.</p> <p>In our application, we have a <code>ListBox</code>, which is populated with what might be a large number of items. Each of these items is displayed with a rather complicated item template. It's necessarily rather complicated, and while it could potentially be pared down a little more I probably couldn't take a huge amount out. The items in the <code>ListBox</code> come from a <code>ListCollectionView</code> which is constructed from an <code>ObservableCollection&lt;&gt;</code> of the objects to display.</p> <p>We have two problems.</p> <p>The first is that when we reconfigure filters for the <code>ListCollectionView</code> and call <code>Refresh</code> on it, there is a very noticable lock-up of a few seconds in the UI while it's torn down and recreated, and the <code>ListBox</code> repopulates. The duration of this lock-up seems to be related to the number of elements contained in the <code>ListBox</code>, and is longest when the <code>ListBox</code>'s client area is full of items. We're pretty certain that the lock-up is caused by the item templates being recreated. I have tried turning on virtualization, but this had no effect in reducing or eliminating the slowdown. I'm also looking at some other optimizations, like examining our bindings and modifying the layouts. Is there any method for either avoiding this particular issue, speeding it up, or moving it to a different thread? (I know the last one's highly unlikely because the rendering is all single-threaded, but perhaps there's some workaround...)</p> <p>The second relates to the filtering on the <code>ListCollectionView</code>. While it isn't an issue at present, we think that there's potential for the filtering to become an issue and cause a noticeable lock-up on the UI thread. I am working to reduce the filtering overhead, but I was wondering if there's a method for moving the Refresh call on the <code>ListCollectionView</code> on to a different thread? None of my attempts thus far have succeeded, seemingly because the <code>ListCollectionView</code> doesn't automatically marshal certain events on to the correct thread.</p> <p>Pointers to or explanations of any known or potential solutions to these two issues would be very helpful.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload