开发者

Detect UP and DOWN arrow button clicks on WPF ListView

I have a very simple ListView which b开发者_如何学编程inds 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


Try this

private void listView_ScrollChanged(object sender, ScrollChangedEventArgs e) {

listView.selectedIndex = Convert.Int16(e.VerticalOffset) }


You can use the attached event ScrollViewer.ScrollChanged

Example

<ListView ScrollViewer.ScrollChanged="listView_ScrollChanged"
          ... />

Event handler

private void listView_ScrollChanged(object sender, ScrollChangedEventArgs e)
{
    // You will end up here everytime the `ListView` is scrolled
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜