DataGrid with AutoCompleteBox crashes Silverlight when scrolling-Collection of common programming errors

I have a Silverlight 4 application with a DataGrid. The rows of the datagrid contain two AutoCompleteBoxes.

Whenever the DataGrid shows a scrollbar and the user scrolls the grid, the entire Silverlight plug-in will freeze and crash. When I run it from the debugger, I usually get the following error right before the freeze/crash:

“Error: Unhandled Error in Silverlight Application Code: 4009 Category: ManagedRuntimeError Message: Element is already the child of another element.”

I have seen several suggestions on possibly related issues on the silverlight.net forums, like avoiding inline item templates, but I have not yet found a working solution.

What I’m looking for is any information related to this: causes, fixes, work-arounds, methods to further analyse the cause of the problem, anything that could help.

  1. One workaround that I’m currently testing, and that seems to work in my scenario, is to put the DataGrid inside a ScrollViewer. This effectively makes the DataGrid as high as it needs to be and delegates the scrolling to the ScrollViewer, so any DataGrid-scrolling-related problems are hereby avoided.

    The only drawback I have found yet (other than that it is a very ugly workaround): the header row of the DataGrid now scrolls out of view, of course, when scrolling down.