What is actually happening in VirtualizingStackPanel.VirtualizationMode = Recycling/Standard.?
Asked
Active
Viewed 1.0k times
1 Answers
45
When VirtualizationMode
is set to Recycling
, the VirtualizingStackPanel
will reuse item containers instead of having to create a new one.
If we start out with this
-------------------------
| Container 1 | Data 1 |
-------------------------
| Container 2 | Data 2 |
-------------------------
| Container 3 | Data 3 |
And scroll one position down, so Data 1 is scrolled out of view and Data 4 is scrolled into view then Recyling will take the item container for Data 1 and reuse it for Data 4.
-------------------------
| Container 2 | Data 2 |
-------------------------
| Container 3 | Data 3 |
-------------------------
| Container 1 | Data 4 |
I've had some problems with this when using attached properties for the Item container, e.g Green background if I have entered edit mode for Container 1. Scrolling down and Data 4 will also have Green background since the Attached Property was still set.
When VirtualizationMode
is set to Standard
, the VirtualizingStackPanel
will create and discard item containers instead of reusing them.

Adi Lester
- 24,731
- 12
- 95
- 110

Fredrik Hedblad
- 83,499
- 23
- 264
- 266
-
2How did you resolved the issue with "repetition"? I have the same problem right now when using TextBlock's Behavior in item template. Strange. – Lukáš Koten Feb 16 '18 at 08:01
-
I resolved it using a view model and binding the property. so every row item has a different view model. – AZ_ Dec 04 '19 at 10:54
-
I don't know if the converter would have worked in this case. So the attached property value is set based on the binding data via value converter. – Bloggrammer Nov 27 '21 at 06:36