开发者

DataGrid with AutoCompleteBox crashes Silverlight when scrolling

开发者 https://www.devze.com 2023-04-11 16:30 出处:网络
I have a Silverlight 4 application with a DataGrid. The rows of the datagrid contain two AutoCompleteBoxes.

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

DataGrid with AutoCompleteBox crashes Silverlight when scrolling

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 开发者_如何学Cfurther analyse the cause of the problem, anything that could help.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号