WPF: Get an event on the scrollbar from Scrollviewer

空扰寡人 提交于 2019-12-02 05:43:54

From how I'm understanding you, you're trying to access the ScrollViewer whenever the user drags the scrollbar left or right. In order to do this, use the ScrollChanged event of the ScrollViewer. In the event handler, you'll have your sender and e arguments. To access properties of the ScrollViewer, simply cast sender as a ScrollViewer like this:

ScrollViewer currentViewer = (ScrollViewer)sender;

That should allow you to access all the information about the ScrollViewer.

If you're having a problem with the width of the Canvas firing the ScrollChanged event, then put a check in the event handler to see if the event is coming from a mouse, or from the Canvas width changing.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!