Hi All,
I need to scroll to an element present in table for WPF application, the value is dynamically provided during run time.
I have below code which runs fine for small listview as scrollbar moves correctly but does not scroll to elements nearing end of long list.
My list is as below and I scroll using names ( A1, A2 ) etc
A1 1 3
A2 1 5
S1 1 3
Q2 1 5
.....
.....
Z7 1 3
Z82 1 5
Z9 1 3
Imports SilkTest.Ntf.Wpf
Public Module Main
Dim _desktop As Desktop = Agent.Desktop
Public Sub Main()
Dim iPosition As Double = 0.5
Dim iSumPosition As Double = 0.0
Dim sObjlocator As String = "//WPFListView[@automationId='MyListView']"
Dim sData As String = "Z118"
Dim sObjSublocator As String = "//WPFToggleButton[@caption='*']"
Dim rows As IList = _desktop.WPFListView(sObjlocator).FindAll(sObjSublocator)
Dim sObjExist As Boolean = False
For Each row As WPFToggleButton In rows
Dim sString As String = row.Text
Console.WriteLine(sString) ' <--names
If Trim(sString) = sData Then
sObjExist = True
Exit For
Else
iSumPosition += iPosition
Console.WriteLine(iSumPosition) ' <--Position
_desktop.WPFListView(sObjlocator).ScrollToPosition(iSumPosition, Orientation.Vertical)
End If
Next
End Sub
End Module
Issue: In output below A1 , A10 etc from Console.WriteLine(sString) and numbers from Console.WriteLine(iSumPosition) ,it works for few objects not in screen and scrollbar moves vertically down but If my list is large and I need scroll many times then I face issue.
Scroll bar does not scroll to end for names nearing end of list, if my list is very small then it scrolls down to very last element as well.
In Debug mode I see rows list (Dim rows As IList = _desktop.WPFListView(sObjlocator).FindAll(sObjSublocator)) does not have value (names) for elements nearing end of list.
In output below ,we can see names & positions are printed initially but in end(for long list) only positions are printed.
Output:
A1
0.5
A10
1
A11
1.5
A12
2
...
...
...
9.5
10
10.5
Any suggestions will be appreciated
Additional info:
WPFScrollBar
WPF pre-fill forms settings is : yes
Tokci