You may receive a system ArgumentNullException exception when you scroll horizontally on a DataGrid control and then click a cell in the control in a .NET Framework 4-based WPF application


Consider the following scenario:
  • You run a Microsoft .NET Framework 4-based Windows Presentation Foundation (WPF) application. 
  • The application contains a DataGrid control.
  • Column virtualization is enabled for the DataGrid control. That is, the DataGrid.EnableColumnVirtualization property is set to True.
  • You scroll horizontally on the DataGrid control and then click a cell in the control. 
In this scenario, the application may crash. If you debug the program, you receive a system ArgumentNullException exception, and the call stack resembles the following:
at System.Windows.Media.VisualTreeHelper.IsAncestorOf(DependencyObject ancestor, DependencyObject descendant, Type stopType)
at System.Windows.Controls.DataGridHelper.ValidateWithoutUpdate(FrameworkElement element)
at System.Windows.Controls.DataGridColumn.CommitCellEdit(FrameworkElement editingElement)
at System.Windows.Controls.DataGridColumn.CommitEdit(FrameworkElement editingElement)
at System.Windows.Controls.DataGridCell.CommitEdit()


This issue occurs when columns are re-virtualized after a horizontal scrolling. The column elements are released. However, the bindings remain in the BindingGroup.BindingExpressions collection of a row. The bindings can be removed by using the DataGridCell.RemoveBindingExpressions method. But this can occur only when the correcting code is triggered. For example, this can occur when a new cell is being edited. If garbage collection occurs before the correcting code is triggered, the BindingExpression.TargetElement is set to null. Then, an invalid value is sent to the VisualTreeHelper.IsAncestorOf method.


Hotfix information

A supported hotfix is now available from Microsoft. However, it is intended to correct only the problem that is described in this article. Apply it only to systems that are experiencing this specific problem. This hotfix may receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next that contains this hotfix.

To resolve this problem immediately, contact Microsoft Customer Support Services to obtain the hotfix. For a complete list of Microsoft Customer Support Services telephone numbers and information about support costs, visit the following Microsoft website:

Note In special cases, charges that are ordinarily incurred for support calls may be canceled if a Microsoft Support Professional determines that a specific update will resolve your problem. The usual support costs will apply to additional support questions and issues that do not qualify for the specific update in question.


You must have the Microsoft .NET Framework 4 installed to install this hotfix. 

Restart requirements

You do not have to restart the computer after you apply the hotfix if all instance of the .NET Framework applications are closed in advance.

Replacement information

This hotfix is not replaced by any later hotfix.

File information

The global version of this hotfix uses a Microsoft Windows Installer package to install the hotfix. The dates and the times for these files are listed in Coordinated Universal Time (UTC) in the following table. When you view the file information, the date is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time item in Control Panel.
For the Microsoft .NET Framework 4 32-bit edition for Windows XP, for Windows Server 2003, for Windows Vista, for Windows Server 2008, and for Windows 7
File nameFile versionFile sizeDateTimePlatform
For the Microsoft .NET Framework 4 64-bit edition for Windows XP, for Windows Server 2003, for Windows Vista, for Windows Server 2008, and for Windows 7
File nameFile versionFile sizeDateTimePlatform


To work around the issue, you must set the DataGrid.EnableColumnVirtualization property to False. However, if you do this, the rendering performance of the application may decrease.


Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

Article ID: 2498911 - Last Review: Apr 25, 2011 - Revision: 1