Why does WP8 LongListSelector incorrectly re-use Checked state of CheckBox?

谁说胖子不能爱 提交于 2019-12-04 07:39:11

Not a bug, although it might look like a bug at first. What you see is the effect of ui virtualization, basically LongListSelector recycles data templates instead of creating new ones to improve performance. One known side effect of recycling is that if your data template contains controls that maintain their own state, CheckBox for example, that state will carry over to the new item.

To solve this issue you need to manage control state externally, i.e. in the view model. In your particular case IsChecked property of CheckBox must be bound to a property of view model. And make sure to use two way binding.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!