locked
strange double value in Scroll viewer's vertical offset ? RRS feed

  • Question

  • Hi all,

    I've a problem with bringing a child control inside a ListViewItem. Here is what i'm trying to achieve : 

    I've a Top level listview which is vertically scrollable but not horizontally. The scroll viewer of my ListView has a Virtualizing panel which in turns support UI Virtualization. I just need to scroll my scroll viewer up to a dynamic offset so that i can bring a grid(which is a child control of my ListViewItem, at the bottom of the ListViewItem) in my view port. The way I've tried is by calculating the height of the ListViewItem and scrolling the scroll viewer's vertical offset to the sum of Present vertical offset+calculated height. 

     The general behavior of ListView's scroll viewer is that, If Virtualized panel is used then vertical offset is count of item(n<sup>th</sup> item in view), or else if a non-virtualizing panel is used then the vertical offset will be in terms of DIPs( Device Independent Pixels). So by this way i've expected a whole number to be my scroll viewer's vertical offset as it supports UI Virtualization. But i'm getting a strange double value like 2.9615384615384626 when item 2's second half part is in view. Not sure how this fraction range has been calculated. So i just wanted to know if i can calculate this fraction range, so that composing the same with the item index as whole number part and the calculated value could be the fraction part may help me to scroll by changing the vertical offset.

    Please let me know if I'm wrong any where and also let me know if there is a way to scroll a Child control of ListViewItem into the view. But the ListView is supposed to provide UI Virtualization.

    Update : I found a similar question here : http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/3594c80a-7ccf-4cfc-9cc0-9731fd080d72

    Thanks in advance

    - Ram



    Sunday, October 21, 2012 7:02 AM

Answers

  • It's very hard to reason without a simple repro project, could you provide that?  Your understanding of ScrollViewer offset seems correct, but if item 2 is scrolled beyond the top of your ScrollViewer, a value > 2 would definitely make sense for vertical offset.  A sample project with "It does A, I want it to do B" type problem statement would be very helpful.

    Thanks,
    Matt


    XAML SDET Lead : Input / DirectManipulation / Accessibility

    • Marked as answer by Jesse Jiang Friday, November 9, 2012 8:04 AM
    Tuesday, October 23, 2012 8:31 PM