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