开发者

WPF ScrollViewer panning

开发者 https://www.devze.com 2023-03-10 06:15 出处:网络
I have a ScrollViewer object in my window that I want to be touch enabled. I have set its PanningMode to HorizontalOnly and it works good, but there are two things that I need to ask:

I have a ScrollViewer object in my window that I want to be touch enabled. I have set its PanningMode to HorizontalOnly and it works good, but there are two things that I need to ask:

1) When the ScrollViewer reaches the end of it's content, the whole window moves upon touching and swiping the object.

2) I need to fire an event when the scroll ends so that I can update some UI stuff.开发者_如何学C What's that event?

Thanks for your help.


1) The bounce is the default behavior with Windows 7 Touch to indicate it's reached the end of a scrollable list.

2) You can attach a listener on the ScrollChanged event. http://msdn.microsoft.com/en-us/library/system.windows.controls.scrollviewer.scrollchanged.aspx

To check "scroll to bottom", compare VerticalOffset (current Y position) == ScrollableHeight (absolute maximium)


Configuring the ScrollViewer like this in the ListView solved the problem (question #1) of the window moving after swiping out of boundaries for me (in case anyone find this useful):

<ListView x:Name="myScrollView" ScrollViewer.PanningMode="None"
ScrollViewer.VerticalScrollBarVisibility="Auto" 
ScrollViewer.HorizontalScrollBarVisibility="Hidden" 
ScrollViewer.CanContentScroll="True" ... >
0

精彩评论

暂无评论...
验证码 换一张
取 消