AutoCompleteComboBox 向上箭头/向下箭头键可滚动列表
我在我的 WPF
应用程序中创建了一个简单的 AutoCompleteBox
,它加载了拦截 Populate 事件的代码,但是当列表弹出时,我按下向下箭头键并进入列表末尾垂直滚动条不滚动。
字段中的值不断变化,就像滚动一样,但滚动条不会移动。
如果我使用鼠标,它滚动得很好。
我只需要箭头键来滚动它。
有什么想法/建议吗?
我是 WPF
的新手,并且一直在寻找此修复程序。
I created a simple AutoCompleteBox
in my WPF
app and it loads great with code intercepting the Populate event, but when the list pops up and I hit the arrow down key and get to the end of the list the vertical scroll bar doesn't scroll.
The values keep changing in the field like it is scrolling through them, but the scroll bar doesn't move.
If I use the mouse it scrolls fine.
I just need the arrow key to scroll it.
Any ideas/suggestions?
I am new to WPF
and have searched forever for this fix.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
附加一个 SelectionChanged 事件,然后在处理程序内:
Attach a SelectionChanged event and then, inside the handler:
我看到同样的行为。我在 codeplex 上发现了一篇 帖子 谈论不同的问题,但在帖子的底部他们有一个支持 ScrollIntoView 的 AutoCompleteBoxEx 类,因此您甚至可以连接 SelectionChanged,这应该会给您带来您想要的行为。我不知道为什么这没有被嵌入。我有机会测试发布的代码。
更新
只需将帖子中的代码粘贴到一个类中,并通过将 AutoCompleteBox 更改为 AutoCompleteBoxEx 并为 AutoCompleteBoxEx 添加命名空间,在 XAML 中使用它,效果很好。您不必在 XAML 中指定任何事件,也不需要在后面的代码中添加任何代码。
I see the same behavior. I found a post on codeplex talking about a different issue but at the bottom of the post they have a class AutoCompleteBoxEx that supports ScrollIntoView, so you can hook up the SelectionChanged even and this should get you the behavior you want. I have no idea why this is not baked in. I have had a chance to test out the posted code.
Update
Just pasted the code from the post into a class and used it in the XAML by changing AutoCompleteBox to AutoCompleteBoxEx and adding namespace for AutoCompleteBoxEx and it worked fine. You don't have to specify any event in the XAML, nor do you need to add any code to the code behind.