Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Event on ScrollViewer's Viewport size changed

I have some custom calculations that changes the dimensions of a control based on the dimensions of a ScrollViewer's viewport. Currently, I make these calculations when getting a ScrollViewer.SizeChanged event. However, it seems like the SizeChanged event executes before the ScrollViewer updates the ViewPort dimensions. My event handler for SizeChanged shows a ScrollViewer sender with the Width and Height updated to the new dimensions but the ViewportWidth and ViewportHeight properties are of the old dimensions.

Is there a way to execute code once those values change?

like image 620
sohum Avatar asked Feb 11 '14 22:02

sohum


1 Answers

According to MSDN you check the ScrollViewer's ScrollChanged event. When it fires, it means the viewportwidth or viewportheight has changed.

OnScrollChanged Called when a change in scrolling state is detected, such as a change in scroll position, extent, or viewport size.

like image 157
gavin Avatar answered Sep 22 '22 18:09

gavin