How to add thousands of items to a binded collection without locking GUI

前端 未结 5 1907
深忆病人
深忆病人 2021-01-31 10:25

I have a setup where potentially thousands of items (think 3000-5000) will be added to an ObservableCollection that is binded to some visual interface. Currently, t

5条回答
  •  感动是毒
    2021-01-31 11:18

    WPF Binding supports concurrency for this reason. Try setting Binding.IsAsync to true. In addition.

    • Don't use ObservableCollection, it is slow for this because each time an item is added it raises events. Use something faster like List and raise your property change notification after all your items are added.
    • Pre-create your items in a background thread, then push them into your collection.
    • Check other parts of code involved to see if there is bloat, and trim.

提交回复
热议问题