简体   繁体   中英

Scroll event for Windows Phone ScrollViewer

In my Windows Phone 8 application I am trying to implement a custom control that behaves like the built-in calendar control which displays the current date above the scrollable content (daily views). Initially I have tried to use the LongListSelector control (which gives me the hierarchical view), but I am not able to determine the scroll position and therefore cannot update the header (the date in the case of the calendar control).

So I switched to using a ScrollViewer control which contains a StackPanel with different controls inside.

Whenever the user scrolls the content I would like to be notified so I can update the UI relative to the content being shown. However, the ScrollViewer doesn't have any explicit scrolling events.

I have tried to use the LayoutUpdated event (which seems to get called frequently enough for my purposes), but when I then update the UI in the event handler another LayoutUpdated event is raised and an infinite loop is created.

How can I update the UI based on the scroll position?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM