问题
How do we detect a scrolling event in GridView (like ViewChanged on ScrollViewer) on somethig like the default GridView template sample app? I'd like to replicate the effect that the netflix App does on the left red strip.
I tried putting the GridView inside a scrollviewer, but I've been unsuccessful at stretching it to fill the screen for different resolutions.
Update: I intend to use this with VariableGrid control that's on NuGet - though it's not an official control, it inherits GridView
回答1:
The best way to do this seems that you can read through the components of the control, and assign events to it. based on what's happening in this example
http://mikaelkoskinen.net/post/WinRT-XAML-Automatically-Scrolling-ListView-to-Bottom-and-Detecting-When-ListView-is-Scrolled.aspx
I grabbed access to the scrollbar, suing the VisualTreeExtensions and I could capture the event Scroll, just like in the example. I had to read the children when the Loaded event of the grid was fired.
回答2:
There is a simpler way.
Edit a template of the GridView, and look inside the XAML to find a ScrollViewer
which is a component of the GridView.
The ScrollViewer
has a ViewChanged
event that you can subscribe to. Now whenever the GridView is scrolled, this event will be fired.
回答3:
Try ManipulationCompleted and PointerReleased events on GridView. This is just using keyboard mouse..
来源:https://stackoverflow.com/questions/13517993/detecting-a-scroll-event-in-gridview-windows-8