2

Silverlight 5 DataGridの列で使用checkboxしています。私はそれに奇妙な問題に直面しています。複数を選択してからグリッドを上下にスクロールすると、選択が他の.itemtemplatecheckboxcheckbox

4

2 に答える 2

3

This is a known behaviour since Silverlight is re-using its graphical resources in the DataGrid. There's a discussion about it in this Silverlight thread.

It seems one way to fix it is to databind the IsSelected property:

My solution at that time was to add a new property in my data source: IsSelected, and to bind the checkbox to that value.

You have more additional info in this thread, where Microsoft answers:

This is not a bug. What happens when you scroll around in the DataGrid is the same checkboxes are being used for new data because the DataGrid recycles the visuals. When your new data has different values, the check will change through the Binding and you'll receive the event. What you can do to get this scenario to work is to listen to LoadingRow which is raised when a row comes into view. In there, you can call column.GetCellContents to get the contents of the cell. This will give you the CheckBox, and you can attach to CheckChanged at this time. If you do this, you need to do something similar and listen to UnloadingRow so you can detach the eventhandler when the checkbox is scrolled out of view.

于 2012-10-18T18:14:28.030 に答える