WP7 Toolkit Update Removed GetItemsInView() from the LongListSelector

后端 未结 3 880
粉色の甜心
粉色の甜心 2021-01-12 19:29

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 suppor

3条回答
  •  攒了一身酷
    2021-01-12 20:20

    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 the LongListSelector.

    The FindScrollViewer solution in kvakulo's answer, however, works.

    If someone needs the VB.Net version of this code:

    Friend Function FindScrollViewer(parent As DependencyObject) As ScrollViewer
    
        Dim childCount = VisualTreeHelper.GetChildrenCount(parent)
    
        For i As Int32 = 0 To childCount - 1
    
            Dim elt = VisualTreeHelper.GetChild(parent, i)
    
            If elt.GetType Is GetType(ScrollViewer) Then Return CType(elt, ScrollViewer)
    
            Dim result = FindScrollViewer(elt)
            If result IsNot Nothing Then Return result
    
        Next
    
        Return Nothing
    
    End Function
    

提交回复
热议问题