How can I know when ItemsSource changes?

天大地大妈咪最大 提交于 2019-12-13 02:59:14

问题


How can I know when items are added to or removed from an ItemsControl. I need to scroll to the top when this happens. I know there is another post on here for doing this using behavior injection, but this doesn't work for me. ScrollToTop is called but the result is not scrolled to the top. Is there another way to do this MVVM style without behavior injection?


回答1:


Look here: MSDN Forums (similar question with answers) Or here: MSDN Documentation (OnItemsSourceChanged method)




回答2:


You could raise an event when ItemsSource is touched, listen for that event, and call ScrolToTop when that event is raised.



来源:https://stackoverflow.com/questions/4890559/how-can-i-know-when-itemssource-changes

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