WPF 列表框显示 SelectedItem 之后的下一个元素
我有带有一堆元素的 TextBox 和 ListBox。
TextBox 有 KeyDown 事件处理程序,其背后的想法是允许用户在焦点位于 TextBox 上时按向上和向下键在 ListBox 内滚动。
当用户多次按下“向下键”时,所选元素将成为屏幕上最后一个可见元素。 如果用户已到达屏幕上可见列表元素的底部,我希望他也能看到所选元素之后的下一个元素。
I have TextBox and ListBox with bunch of elements.
TextBox has KeyDown event handler, the idea behind this is to allow user to press up and down keys to scroll inside ListBox while focus is on TextBox.
When user presses "down key" several times, selected element becomes last visible element on screen. If user has reached bottom of visible list element on screen, I want him to see next element after selected element as well.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看 ScrollIntoView 方法列表框。 您可以使用它来确保所选元素的下一个元素始终可见。
按向下箭头:
按向上箭头:
Look at the ScrollIntoView method on the listbox. You can use this to ensure that the next element to the selected one is always visible.
On down arrow press:
On up arrow press: