WP 8.1 ISupportIncrementalLoading LoadMoreItemsAsync keeps getting called endlessly

旧街凉风 提交于 2019-12-05 17:05:49

As you mentioned in your answer, the StackPanel was the culprit. The StackPanel control won't constrain the size of its content. This means as your ListView loads more items, the height of the ListView will also grow inside the StackPanel, and so the ListView thinks that every item is visible, so it loads more items, and so on.

This also affects virtualization too, which is another reason why you should never put a ListView inside a StackPanel. According to the docs:

When the size of the ItemsControl's viewport isn't restricted, the control doesn't perform virtualization. Instead, it creates an item container for each item in its collection. Some common containers that don't restrict the viewport size are Canvas, StackPanel, and ScrollViewer. You can enable virtualization in this situation by setting the size of ItemsControl directly, instead of letting it be sized by its parent container.

So your options are:

  • Don't use a StackPanel container. Use a Grid instead.
  • If you want to use a StackPanel container then you must manually set the size (height) of the ListView.

After playing around I managed to solve this. The problem was the StackPanel in which the ListView was in. I dont know why but for some reason the existence of the StackPanel caused the LoadMoreItemsAsync getting called endlessly and as soon as I removed it, it worked fine.

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