Yes, the WPF DataGrid has built in support for virtualization. By default theVirtualizingStackPanel .IsVirtualizing property is set to true, so by default the virtualization is used on the DataGrid, and you can specify the VirtualizingStackPanel.VirtualizationMode to either Standard or Recycling .
By default, a VirtualizingStackPanel creates an item container for each visible item and discards it when it is no longer needed (such as when the item is scrolled out of view). When an ItemsControl contains a many items, the process of creating and discarding item containers can negatively affect performance. When VirtualizationMode is set to Recycling, the VirtualizingStackPanel reuses item containers instead of creating a new one each time. For example, you can use Recycling mode like this: <my:DataGrid AutoGenerateColumns="True" ItemsSource="{Binding}" Margin="11,20,8,9" Name="dataGrid1" VirtualizingStackPanel.VirtualizationMode="Recycling" />
DataGrid.EnableColumnVirtualization
如果启用列虚拟化,则为 true,否则为 false。 注册的默认值为 false。 DataGrid.EnableRowVirtualization 如果启用行虚拟化,则为 true,否则为 false。 注册的默认值为 true。
这样设置会提高用户体验:
EnableColumnVirtualization="True"
EnableRowVirtualization="True"
ScrollViewer.IsDeferredScrollingEnabled ="True"
VirtualizingStackPanel.IsVirtualizing="True"
VirtualizingStackPanel.VirtualizationMode="Recycling"
AutoGenerateColumns="False">