What is Virtualizing StackPanel?


Virtualizing StackPanel generates container items when needed & throws them from memory when they are no longer in the view. When the pa... - Article authored by Kunal Chowdhury on .

Virtualizing StackPanel generates container items when needed & throws them from memory when they are no longer in the view. When the panel has huge number of items, at that time there is no need to keep the extra items in memory which are not in view. This solves the memory problem.

If you are populating a huge number of items in any panel, then it is a better idea to use the Virtualization. But, due to throwing away of the extra items & recreating them when in view, costs some extra processing power when the Virtualizing StackPanel uses the default Standard Mode. To solve this issue, just change the virtualization mode to "Recycling". This is called as Container Recycling, which introduced in .Net 3.5 SP1 as a new feature.

By default, this recycling mode is turned off. To enable the container recycling, first turn on the Virtualizing StackPanel with “VirtualizationModeProperty” as “Recycling”.

<WrapPanel x:Name="wrpPanel" VirtualizingStackPanel.IsVirtualizing="true" VirtualizingStackPanel.VirtualizationMode="Recycling" />

You can also use GetVirtualizationMode() & SetVirtualizationMode() to get or set the current mode.

Have a question? Or, a comment? Let's Discuss it below...

dhgate

Thank you for visiting our website!

We value your engagement and would love to hear your thoughts. Don't forget to leave a comment below to share your feedback, opinions, or questions.

We believe in fostering an interactive and inclusive community, and your comments play a crucial role in creating that environment.