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

Article translations Article translations
Article ID: 2498911 - View products that this article applies to.
Expand all | Collapse all

On This Page

SYMPTOMS

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()

CAUSE

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.

RESOLUTION

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:

http://support.microsoft.com/contactus/?ws=support

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.

Prerequisites

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
Collapse this tableExpand this table
File nameFile versionFile sizeDateTimePlatform
Presentationcore.dll4.0.30319.4523,789,15207-Apr-201107:09x86
Presentationframework.dll4.0.30319.4526,431,08007-Apr-201107:09x86
Windowsbase.dll4.0.30319.4521,371,48007-Apr-201107:09x86
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
Collapse this tableExpand this table
File nameFile versionFile sizeDateTimePlatform
Presentationcore.dll4.0.30319.4523,824,99207-Apr-201108:06x64
Presentationframework.dll4.0.30319.4526,431,08007-Apr-201107:09x64
Windowsbase.dll4.0.30319.4521,371,48007-Apr-201107:09x64

WORKAROUND

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.

STATUS

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

Properties

Article ID: 2498911 - Last Review: April 25, 2011 - Revision: 1.0
APPLIES TO
  • Microsoft .NET Framework 4
Keywords: 
kbqfe kbhotfixserver kbfix kbexpertiseadvanced kbsurveynew KB2498911

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com