Crash using NewRowTemplateBehavior with .NET 4.0 DataGrid

WPF Studio, Themes, and Shared Library for WPF Forum

Posted 14 years ago by Phil Devaney - Senior Software Engineer, Serck Controls Ltd
Version: 9.2.0512
Platform: .NET 4.0
Environment: Windows Vista (64-bit)
Avatar
If I set NewRowTemplateBehavior.Template on a .NET 4.0 DataGrid (i.e. the one from System.Windows.Controls), using the template from the sample application, and bind ItemsSource to an ObservableCollection, then I get a crash if I call Clear on the source collection.

The crash is a NullReferenceException inside framework code, the last user function on the stack is OnDataGridUnloadingRow, on the line e.Row.UpdateLayout(). This only happens with the .NET 4.0 DataGrid, the one from WpfToolkit is OK.

If I remove the call to UpdateLayout then it doesn't crash, and there are no immediately obvious adverse effects. I know you aren't supporting .NET 4 just yet, so I can live with this for now.

I have emailed a sample project showing the problem to support.

Comments (1)

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Phil,

The NewRowTemplateBehavior.OnDataGridUnloadingRow method includes a call to e.Row.UpdateLayout(). This code is meant to refresh the row, which may not display correctly after the Template was changed.

From what we can tell this code is not needed for the .Net 4 version of DataGrid, but is still required for the WPFToolkit version. So you can either remove that line altogether, or add NullReferenceException to the try-catch block.

We've had other reports of NullReferenceException's being raised from .Net 4 version of the DataGrid in other locations, so it appears this might be a larger .Net 4 issue (which will hopefully be resolved before it's released).


Actipro Software Support

The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.