11

There is almost no information out there about the impact of setting;

VirtualizingStackPanel.IsVirtualizing="True" 

and

EnableRowVirtualization="True" EnableColumnVirtualization="True". 

Can someone clarify what the difference is?

Also, as an added bonus, can anyone clarify if EnableRowVirtualization and EnableColumnVirtualization actually do anything on the 3.5 grid as the MSDN documentation only lists these properties back to 4.0, but they definitely exist in 3.5?

Thanks.

Ray Booysen
  • 28,894
  • 13
  • 84
  • 111
Julius
  • 735
  • 1
  • 9
  • 25

1 Answers1

11

Both IsVirtualizing and EnableRowVirtualization/EnableColumnVirtualization operate on the same principle, which is that items are visualized only when needed and the containers are reused.

Essentially, the Panel (or Grid) keeps track of what is visible and if this is changed, it uses an internal class, 'ItemContainerGenerator', to size and build new items (https://learn.microsoft.com/en-us/dotnet/api/system.windows.controls.itemcontainergenerator).

The motivation for both is that the containers are only generated on demand thus saving memory and improving performance.

As to why there are two: the Panel is designed to extend in a single direction only, either horizontal or vertical; so they implemented a single attached property for it. A Grid, on the other hand, extends in two dimensions, so they implemented a property for each dimension.

The other difference is academic: IsVirtualizing is an attached property, wherease its counterparts for the Grid are native properties. No clue as to why they opted for this difference...

Relevant links are https://learn.microsoft.com/en-us/dotnet/api/system.windows.controls.datagrid.enablerowvirtualization and https://learn.microsoft.com/en-us/dotnet/api/system.windows.controls.virtualizingstackpanel.isvirtualizing

MHN
  • 103
  • 2
  • 7
Gayot Fow
  • 8,710
  • 1
  • 35
  • 48
  • 1
    Interesting clarification concerning the direction of the EnableRowVirtualization/EnableColumnVirtualization properties. Can you further clarify the impact of setting the attached property instead of/as well as the EnableRowVirtualization/EnableColumnVirtualization properties? I understand that they turn on/off the same sort of behaviour, but I still don't understand whether one can be used over the other, i.e. do they have completely overlapping responsibilities, or actually do different things under the hood? – Julius Sep 24 '13 at 09:25
  • The behaviour is implemented at the *ItemsControl* level, so affects classes derived from it. 'Under the hood' there are no conspicuous differences in the algorithm other than directionality. Also... It's not really a choice of using one setting over the other because native properties should be used when they are available. – Gayot Fow Sep 24 '13 at 09:37