Reputation: 3
I have a WPF Grid and a list of values. The list of values have a row and column property and the content value. There are between 200 and 14,000 values to be displayed in a formatted grid.
I have added rows and columns to the grid then added text blocks to the grid in the correct row/column positions.
This works great till I have around 8,000 values then it slows down. To remedy I put it out to a thread to perform the layout, problem is, my TextBlocks are created on one thread then when I try to add them to the Children member of the Grid using the UI dispatcher the text block is on a different thread.
So the question is, can I switch the thread affinity of the Textblocks to the UI thread after I've created them?
Thanks Owen
Upvotes: 0
Views: 291
Reputation: 12954
Are you going to show all the 8000 values at once or are you having some scrollbars?
Adding 8000 controls to a view would be considered a bad design.
Why don't you go for a ListView and template it according your design if the values have the same template? So that you can bind it to an ObservableCollection which could be filled up using the List of Values you have. The fill could be made asynchronous using Dispatcher's BeginInvoke method
Upvotes: 1