There's actually much more to it than just making the ItemsPanelTemplate use VirtualizingStackPanel. The default ControlTemplate for ItemsControl does not have a ScrollViewer, which is the key to virtualization. Adding to the the default control template for ItemsControl (using the control template for ListBox as a template) gives us the following.
There's actually much more to it than just making the ItemsPanelTemplate use VirtualizingStackPanel. The default ControlTemplate for ItemsControl does not have a ScrollViewer, which is the key to virtualization. Adding to the the default control template for ItemsControl (using the control template for ListBox as a template) gives us the following: (BTW, a great tool for looking at default control templates is Show Me The Template) Things to notice: You have to set ScrollViewer.
CanContentScroll="True", see here for why. Also notice that I put VirtualizingStackPanel. VirtualizationMode="Recycling".
This will reduce the numbers of times TextBlock_Initialized is called to however many TextBlocks are visible on the screen. You can read more on UI virtualization here . EDIT: Forgot to state the obvious: as an alternate solution, you can just replace ItemsControl with ListBox :) Also, check out this Optimizing Performance on MSDN page and notice that ItemsControl isn't in the "Controls That Implement Performance Features" table, which is why we need to edit the control template.
1 +1 for the Show Me the Template link. What a great tool! – Metro Smurf May 6 '10 at 21:07 Thank you, that is exactly the sort of thing I was looking for!
I was looking for a different kind of selection behavior than a listbox and at the time I thought it would be easiest to do with an items control. – Rachel May 7 '10 at 12:20 ListView works for this also. – Scott A.
Lawrence Aug 10 '10 at 20:20.
It is just that the default ItemsPanel isn't a VirtualizingStackPanel. You need to change it.
Thanks, but I already tried this and it didn't work. – Rachel May 7 '10 at 12:22.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.