AutoCompleteBox:不使用向上/向下键进行验证
当选择更改时(通常是通过鼠标),我的 AutoCompleteBox 会调用 WCF 服务。但是,如果用户使用箭头键在选择中导航,则会为每个元素触发该事件,从而使应用程序的数据密集程度过高。 如何防止 AutoCompleteBox_SelectionChanged 在按下按键时触发?
我发现这听起来像是一个不错的解决方案,但它不起作用 http:// betaforums.silverlight.net/forums/p/137710/307786.aspx
My AutoCompleteBox calls a WCF service when the selection is changed, usually with the mouse. However if the user uses the arrow keys to navigate through the selection, the event fires up for each element, making the application too much data intensive.
How do I prevent the AutoCompleteBox_SelectionChanged to fire when the keys are pressed?
I found this which sounded like a nice solution but it doesn't work http://betaforums.silverlight.net/forums/p/137710/307786.aspx
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好的,我没有使用 AutoCompleteBox_SelectionChanged,而是使用 AutoCompleteBox_DropDownClosed,这解决了问题。
ok, rather than using AutoCompleteBox_SelectionChanged, I'm using AutoCompleteBox_DropDownClosed, and this fixed the problem.
我刚刚发现我是如何解决同样的问题的。另外我没有使用 SelectionChanged。
我向项目 DataTemplate 添加了行为(到网格根)。此行为将单击处理程序附加到项目。当使用按键时,行为处于“睡眠”状态,当我用鼠标单击项目时,行为会被调用并使其工作。 (此外,我将项目所需的属性绑定到 DataTemplate 的 Grid 的 Tag 属性,这样我就可以从行为中获取它)
并不适合每个解决方案,但可能很有用。
I just found how I have solved this same problem. Also I am not using SelectionChanged.
I added behavior to item DataTemplate (to Grid root). This behavior attach click handler to item. When keys are used, behavior is "sleeping", when I click on item with mouse, behavior get called and make its work. (Also I bind needed property of item to a DataTemplate's Grid's Tag property, so I can get to it from behavior)
Not suitable for every solution, but can be useful.