AutoCompleteComboBox 向上/向下箭头键滚动列表 [英] AutoCompleteComboBox Arrow Up/Arrow Down keys to scroll list

查看:37
本文介绍了AutoCompleteComboBox 向上/向下箭头键滚动列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的 WPF 应用程序中创建了一个简单的 AutoCompleteBox 并且它加载了很好的代码拦截 Populate 事件,但是当列表弹出时我按下箭头键并到达列表末尾,垂直滚动条不滚动.

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.

有什么想法/建议吗?

我是 WPF 的新手,并且一直在寻找此修复程序.

I am new to WPF and have searched forever for this fix.

推荐答案

我看到了相同的行为.我发现一个 关于 codeplex 的帖子 讨论了一个不同的问题,但在帖子的底部,他们有一个类 AutoCompleteBoxEx 支持 ScrollIntoView,因此您甚至可以连接 SelectionChanged,这应该可以让您获得所需的行为.我不知道为什么没有加入.我有机会测试发布的代码.

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.

更新

刚刚将帖子中的代码粘贴到一个类中,并通过将 AutoCompleteBox 更改为 AutoCompleteBoxEx 并为 AutoCompleteBoxEx 添加命名空间在 XAML 中使用它,并且它工作正常.您不必在 XAML 中指定任何事件,也无需向后面的代码添加任何代码.

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.

这篇关于AutoCompleteComboBox 向上/向下箭头键滚动列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆