WP7 工具包更新从 LongListSelector 中删除了 GetItemsInView()
通过 Windows Phone Toolkit 的最新更新,他们彻底修改了 Mango 版本的 LongListSelector 的内部结构。其中一项更改是删除对 GetItemsInView()
函数的支持(它现在返回一个空列表)。该函数之前返回当前在屏幕上可见的项目列表。当离开页面时,我使用它来获取对最顶层可见项目的引用,以便我可以使用 ScrollTo(object item)
支持逻辑删除后的恢复。
有谁知道建议的替代方案是什么?我知道对于 Mango 墓碑来说问题要小得多,但我仍然想支持它,并且可能在其他一些情况下我想回忆滚动位置。在某些情况下,我的清单有数千个项目。
With the latest update to the Windows Phone Toolkit they have overhauled the internals of the LongListSelector for the Mango release. One of the changes was removing support for the GetItemsInView()
function (it now returns an empty list). This function previously returned a list of items that were currently visible on the screen. I was using this to get a reference to the topmost visible item when navigating away from a page so that I could support recovery after a tombstone by using ScrollTo(object item)
.
Does anyone know what the suggested alternative would be? I know that with Mango tombstoning is much less of an issue, but I'd still like to support it and there may be some other scenarios where I'd want to recall the scroll position. My list has thousands of items in some cases.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
据我从新的位来看,您必须订阅 LLS 的
Link
和Unlink
事件。Link
将传入一个参数,其中包含添加到 LLS 可见部分的项目。Unlink
对于从 LLS 中删除的项目执行相同的操作。因此,您需要执行以下操作:请注意,
Link
和Unlink
将为基础列表中的每个渲染项目触发,因此,如果您使用的是LLS,那么您必须根据实际返回的类型来增强是否跟踪该项目的测试。因此,如果您有某种组对象想要跟踪其底层对象,您可能会执行以下操作:我希望这会有所帮助!如果成功请告诉我们。
From what I can tell from the new bits, you have to subscribe to the LLS's
Link
andUnlink
events.Link
will pass in an arg that contains the item added to the visible part of the LLS.Unlink
does the same for those items removed from the LLS. So you'd do something like this:Note that
Link
andUnlink
will fire for EVERY rendered item in the underlying list, so if you're using the grouping features of the LLS, then you'll have to augment your test on whether or not to track the item based on what type is actually coming back. So if you have some sort of group object for which you want to track the underrlying objects, you might do something like this:I hope this helps! Let us know if it works out.
LongListSelector
在内部使用ScrollViewer
(显然自 2011 年 8 月发布以来)。这一事实可用于按照 http://damianblog.com/2011/01/21/wp7-scroll-pivot/ 用于枢轴控制器。在
OnNavieratedFrom()
中记住滚动偏移量:如果应用程序已被逻辑删除,则在
OnNavieratedTo()
中恢复它:The
LongListSelector
is using aScrollViewer
internally (apparently since the Aug 2011 release). This fact can be used to restore the position of the list after tombstoning by following the example given at http://damianblog.com/2011/01/21/wp7-scroll-pivot/ for the pivot controller.In
OnNavigatedFrom()
remember the scroll offset:And restore it in
OnNavigatedTo()
if the app have been tombstoned:链接/取消链接方法对于恢复滚动位置根本不起作用。即使您设置了集合,您也不知道是向上还是向下滚动,并且集合的大小会根据
LongListSelector
的BufferSize
属性而变化。 。然而,kvakulo 的答案中的 FindScrollViewer 解决方案是有效的。
如果有人需要此代码的 VB.Net 版本:
The Link/Unlink approach does not work at all for restoring the scroll position. Even if you setup the collection, you don't know if you are scrolling up or down, and the size of the collection would vary depending on the
BufferSize
property of theLongListSelector
.The
FindScrollViewer
solution in kvakulo's answer, however, works.If someone needs the VB.Net version of this code: