locked
Determine if GridViewItem in GridView is in the view of the user RRS feed

  • Question

  • Is there a way to "ask" the GridView control if a specific GridViewItem is being displayed on the screen?

    I'm not waiting to know if a GridViewItem has been attached to the Items property of the GridView, I want to know if the actual GridViewItem is showing up on the display or if the user has scrolled the GridView to the point that the specific GridViewItem is no longer being displayed.

    Monday, September 16, 2013 4:27 PM

Answers

  • There isn't a direct notification of this, so you will need to track it the way I described in my previous note. You can detect when the GridView scrolls and then check to see which items you're tracking are visible.

    --Rob

    Thursday, September 26, 2013 1:20 AM
    Moderator

All replies

  • If you already have the GridViewItem then you can use the VisualTreeHelper to see if and where it is displayed.

    The tricky part is finding the GridViewItem if you only have the underlying data. You can force the item to appear with ScrollIntoView, but there isn't a straightforward way to go from the underlying data to the GridViewItem on Windows 8. On Windows 8.1 you can call ContainerFromItem to get the GridViewItem and then use the VisualTreeHelper to see where that GridViewItem is.

    --Rob

    Tuesday, September 17, 2013 1:37 AM
    Moderator
  • Basically what I need to do is, I have a video that is streaming from a GridView control. If the GridViewItem from which the video is playing on is scrolled off the screen I want to pause the video until its in view again. In addition, I have a few Items in the same GridView that have pictures that change. When those items are scrolled off the screen I don't want them to be refreshed until the GridViewItem comes back into view.
    Tuesday, September 17, 2013 1:41 AM
  • There isn't a direct notification of this, so you will need to track it the way I described in my previous note. You can detect when the GridView scrolls and then check to see which items you're tracking are visible.

    --Rob

    Thursday, September 26, 2013 1:20 AM
    Moderator