× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

Difference between WPF DataGrid's EnableRowVirtualization and VirtualizingStackPanel.IsVirtualizing properties

Gayot Fow
Feb 05, 2015
<p>Both <code>IsVirtualizing</code> and <code>EnableRowVirtualization</code>/<code>EnableColumnVirtualization</code> operate on the same principle, which is that items are visualized only when needed and the containers are reused. </p> <p>Essentially, the <code>Panel</code> (or <code>Grid</code>) keeps track of what is visible and if this is changed, it uses an internal class, <code>'ItemContainerGenerator'</code>, to size and build new items (<a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.itemcontainergenerator.aspx">http://msdn.microsoft.com/en-us/library/system.windows.controls.itemcontainergenerator.aspx</a>).</p> <p>The motivation for both is that the containers are only generated on demand thus saving memory and improving performance.</p> <p>As to why there are two: the <code>Panel</code> is designed to extend in a single direction only, either horizontal or vertical; so they implemented a single attached property for it. A <code>Grid</code>, on the other hand, extends in two dimensions, so they implemented a property for each dimension. </p> <p>The other difference is academic: <code>IsVirtualizing</code> is an attached property, wherease its counterparts for the <code>Grid</code> are native properties. No clue as to why they opted for this difference... </p> <p>Relevant links are <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.datagrid.enablerowvirtualization(v=vs.100).aspx">http://msdn.microsoft.com/en-us/library/system.windows.controls.datagrid.enablerowvirtualization(v=vs.100).aspx</a> and <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.virtualizingstackpanel.isvirtualizing.aspx">http://msdn.microsoft.com/en-us/library/system.windows.controls.virtualizingstackpanel.isvirtualizing.aspx</a></p> <p>This tip was originally posted on <a href="http://stackoverflow.com/questions/18976856/Difference%20between%20WPF%20DataGrid's%20EnableRowVirtualization%20and%20VirtualizingStackPanel.IsVirtualizing%20properties/18977332">Stack Overflow</a>.</p>

Get New Tutorials Delivered to Your Inbox

New tutorials will be sent to your Inbox once a week.

comments powered by Disqus