检测 WPF ListView 上的向上和向下箭头按钮单击
我有一个非常简单的 ListView,它绑定到字符串的 ObservableCollection。我可以使用“ScrollBar.Scroll”属性来检测何时有人单击滚动条并将其向上或向下拖动,但是如何检测何时他们单击 ScrollBar 顶部和底部的向上或向下按钮?单击这些似乎不会触发滚动事件。
我确信这一定是简单的事情,但我已经搜索了大约一个小时但没有成功。
TIA
I have a very simple ListView which binds to an ObservableCollection of strings. I can use the 'ScrollBar.Scroll' property to detect when someone clicks on the scroll bar and tugs it up or down, but how do you detect when they click the UP or DOWN buttons at the top and bottom of the ScrollBar? Clicking these does not seem to fire the Scroll event.
I'm sure it must be something straight-forward, but I've searched for about an hour without success.
TIA
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
试试这个
private void listView_ScrollChanged(object sender, ScrollChangedEventArgs e)
{
listView.selectedIndex = Convert.Int16(e.VerticalOffset)
}
Try this
private void listView_ScrollChanged(object sender, ScrollChangedEventArgs e)
{
listView.selectedIndex = Convert.Int16(e.VerticalOffset)
}
您可以使用附加事件
ScrollViewer.ScrollChanged
示例
事件处理程序
You can use the attached event
ScrollViewer.ScrollChanged
Example
Event handler