4

在我的 WP8 应用程序中,我正在尝试实现一个功能,该功能将允许我保存LongMultiListSelector的滚动位置并在以后将其滚动到该位置(例如在墓碑之后)。事实证明这是一项艰巨的任务,尽管取得了一些进展,但我仍然有疑问。

据我所知,我现在需要以下东西才能工作:

  1. 显然可以滚动到我现在拥有的指定项目。(LongMultiListSelector尽管是 的扩展LongListSelector,但没有ScrollTo方法,尽管LongListSelector可以在LongMultiListSelector的可视化树中找到,这就是我所做的)。

    1.1。能够滚动到带有动画的指定项目,而这个我还没有解决。它不是那么重要,但拥有它会很好。经过一番搜索,我发现曾经LongListSelectorAnimateTo方法,但目前没有。

  2. 能够找出LongListSelector当前在屏幕上可见的项目,以便我可以保存这些可见项目之一的索引,然后滚动到它。这个我也没有解决,非常重要。

    经过一番搜索,我发现了这个问题:WP7 Toolkit Update Removed GetItemsInView() from the LongListSelector。是说,在以前LongListSelector有一个GetItemsInView功能,在后来它有LinkUnlink事件,特别是为了这个目的。目前LongListSelector没有这两个选项。

    所以主要问题是我现在应该怎么做才能找到可见的项目LongListSelector

4

2 回答 2

4

I looks like currently there's no easy and direct way at all to find which items are visible. Fortunately not everything is lost. Both ScrollBar and LongListSelector can be found in LongListSelector's visual tree at runtime.

LongListSelector is needed for it's ScrollTo method and from ScrollBar I need a ValueChanged event where I can get ScrollBar.Maximum and ScrollBar.Value which are control height and current offset, respectively. The problem again is that these two properties are not always calculated correctly perhaps due to LongListSelector's virtualization and the fact that it does not show all the items at once. Good thing is that negative distance (Maximum - Value, an offset from end of list) is, although relative, always right.

So if it's possible for you to manually calculate real height of your LongListMultiSelector then scroll management becomes possible using that real height and negative distance. In my case it was easy because all of the items are of the same height.

于 2013-02-05T07:58:42.990 回答
0

回答能力滚动到带有动画的指定项目

这篇文章会帮助你。

主要思想:ScrollViewerVerticalOffset Property被标记为只读。因此,您可以创建一个 shell 类来帮助您为 VerticalOffset 设置动画。

于 2013-08-07T12:45:41.083 回答